Skip to content

Commit

Permalink
test: Directly constructing 2 entry map for getprioritisedtransactions
Browse files Browse the repository at this point in the history
Directly constructing the map so that we wouldn't miss extraneous
entries in future regressions.
  • Loading branch information
kevkevinpal committed Nov 13, 2023
1 parent 0387ca0 commit 80f7ccd
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/functional/mining_prioritisetransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ def test_diamond(self):
raw_after = self.nodes[0].getrawmempool(verbose=True)
assert_equal(raw_before[txid_a], raw_after[txid_a])
assert_equal(raw_before, raw_after)
prioritisation_map_in_mempool = self.nodes[0].getprioritisedtransactions()
assert_equal(prioritisation_map_in_mempool[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True})
assert_equal(prioritisation_map_in_mempool[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True})
# Clear prioritisation, otherwise the transactions' fee deltas are persisted to mempool.dat and loaded again when the node
# is restarted at the end of this subtest. Deltas are removed when a transaction is mined, but only at that time. We do
# not check whether mapDeltas transactions were mined when loading from mempool.dat.
Expand All @@ -126,17 +125,15 @@ def test_diamond(self):
self.nodes[0].prioritisetransaction(txid=txid_b, fee_delta=int(fee_delta_b * COIN))
self.nodes[0].prioritisetransaction(txid=txid_c, fee_delta=int(fee_delta_c_1 * COIN))
self.nodes[0].prioritisetransaction(txid=txid_c, fee_delta=int(fee_delta_c_2 * COIN))
prioritisation_map_not_in_mempool = self.nodes[0].getprioritisedtransactions()
assert_equal(prioritisation_map_not_in_mempool[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : False})
assert_equal(prioritisation_map_not_in_mempool[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : False})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : False})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : False})
for t in [tx_o_a["hex"], tx_o_b["hex"], tx_o_c["hex"], tx_o_d["hex"]]:
self.nodes[0].sendrawtransaction(t)
raw_after = self.nodes[0].getrawmempool(verbose=True)
assert_equal(raw_before[txid_a], raw_after[txid_a])
assert_equal(raw_before, raw_after)
prioritisation_map_in_mempool = self.nodes[0].getprioritisedtransactions()
assert_equal(prioritisation_map_in_mempool[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True})
assert_equal(prioritisation_map_in_mempool[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_b], {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True})
assert_equal(self.nodes[0].getprioritisedtransactions()[txid_c], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True})

# Clear mempool
self.generate(self.nodes[0], 1)
Expand Down

0 comments on commit 80f7ccd

Please sign in to comment.