aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <[email protected]>2017-06-05 19:32:56 +0000
committerLuke Dashjr <[email protected]>2017-06-05 19:33:01 +0000
commit74653a41fee027b1c85b229a2d7460bb862c6b02 (patch)
treea0c68f3d637aad0ae6daacf1ef7752e0d56e77ee
parentdoc: Preliminary release notes 0.14.2 (diff)
parent[qa] Test prioritise_transaction / getblocktemplate interaction (diff)
downloaddiscoin-74653a41fee027b1c85b229a2d7460bb862c6b02.tar.xz
discoin-74653a41fee027b1c85b229a2d7460bb862c6b02.zip
Merge #10196 via branch 'prioritisetx_gbtcache-0.14' into 0.14.2_fixes
-rwxr-xr-xqa/rpc-tests/prioritise_transaction.py16
-rw-r--r--src/txmempool.cpp1
-rw-r--r--src/txmempool.h2
3 files changed, 17 insertions, 2 deletions
diff --git a/qa/rpc-tests/prioritise_transaction.py b/qa/rpc-tests/prioritise_transaction.py
index b7459c80c..16874a6b5 100755
--- a/qa/rpc-tests/prioritise_transaction.py
+++ b/qa/rpc-tests/prioritise_transaction.py
@@ -16,7 +16,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
def __init__(self):
super().__init__()
self.setup_clean_chain = True
- self.num_nodes = 1
+ self.num_nodes = 2
self.txouts = gen_return_txouts()
@@ -25,8 +25,11 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
self.is_network_split = False
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-printpriority=1"]))
+ self.nodes.append(start_node(1, self.options.tmpdir, ["-debug", "-printpriority=1"]))
+ connect_nodes(self.nodes[0], 1)
self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']
+
def run_test(self):
utxo_count = 90
utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], utxo_count)
@@ -139,5 +142,16 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
assert_equal(self.nodes[0].sendrawtransaction(tx2_hex), tx2_id)
assert(tx2_id in self.nodes[0].getrawmempool())
+ # Test that calling prioritisetransaction is sufficient to trigger
+ # getblocktemplate to (eventually) return a new block.
+ mock_time = int(time.time())
+ self.nodes[0].setmocktime(mock_time)
+ template = self.nodes[0].getblocktemplate()
+ self.nodes[0].prioritisetransaction(txid, 0, -int(self.relayfee*COIN))
+ self.nodes[0].setmocktime(mock_time+10)
+ new_template = self.nodes[0].getblocktemplate()
+
+ assert(template != new_template)
+
if __name__ == '__main__':
PrioritiseTransactionTest().main()
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 91040fb9b..72547b582 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -945,6 +945,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256 hash, const std::string str
BOOST_FOREACH(txiter descendantIt, setDescendants) {
mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0));
}
+ ++nTransactionsUpdated;
}
}
LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, FormatMoney(nFeeDelta));
diff --git a/src/txmempool.h b/src/txmempool.h
index db1a02455..12c9e59f5 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -432,7 +432,7 @@ class CTxMemPool
{
private:
uint32_t nCheckFrequency; //!< Value n means that n times in 2^32 we check.
- unsigned int nTransactionsUpdated;
+ unsigned int nTransactionsUpdated; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
CBlockPolicyEstimator* minerPolicyEstimator;
uint64_t totalTxSize; //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141.