Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_packages.py
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
v_descendants = self.nodes[0].getmempooldescendants(chain[0], True) | v_descendants = self.nodes[0].getmempooldescendants(chain[0], True) | ||||
assert_equal(len(v_descendants), len(chain) - 1) | assert_equal(len(v_descendants), len(chain) - 1) | ||||
for x in v_descendants.keys(): | for x in v_descendants.keys(): | ||||
assert_equal(mempool[x], v_descendants[x]) | assert_equal(mempool[x], v_descendants[x]) | ||||
assert chain[0] not in v_descendants.keys() | assert chain[0] not in v_descendants.keys() | ||||
# Check that ancestor modified fees includes fee deltas from | # Check that ancestor modified fees includes fee deltas from | ||||
# prioritisetransaction | # prioritisetransaction | ||||
self.nodes[0].prioritisetransaction(chain[0], 0, 1000) | self.nodes[0].prioritisetransaction(chain[0], 1000) | ||||
mempool = self.nodes[0].getrawmempool(True) | mempool = self.nodes[0].getrawmempool(True) | ||||
ancestor_fees = 0 | ancestor_fees = 0 | ||||
for x in chain: | for x in chain: | ||||
ancestor_fees += mempool[x]['fee'] | ancestor_fees += mempool[x]['fee'] | ||||
assert_equal(mempool[x]['fees']['ancestor'], | assert_equal(mempool[x]['fees']['ancestor'], | ||||
ancestor_fees + Decimal('0.00001')) | ancestor_fees + Decimal('0.00001')) | ||||
assert_equal(mempool[x]['ancestorfees'], | assert_equal(mempool[x]['ancestorfees'], | ||||
ancestor_fees * COIN + 1000) | ancestor_fees * COIN + 1000) | ||||
# Undo the prioritisetransaction for later tests | # Undo the prioritisetransaction for later tests | ||||
self.nodes[0].prioritisetransaction(chain[0], 0, -1000) | self.nodes[0].prioritisetransaction(chain[0], -1000) | ||||
# Check that descendant modified fees includes fee deltas from | # Check that descendant modified fees includes fee deltas from | ||||
# prioritisetransaction | # prioritisetransaction | ||||
self.nodes[0].prioritisetransaction(chain[-1], 0, 1000) | self.nodes[0].prioritisetransaction(chain[-1], 1000) | ||||
mempool = self.nodes[0].getrawmempool(True) | mempool = self.nodes[0].getrawmempool(True) | ||||
descendant_fees = 0 | descendant_fees = 0 | ||||
for x in reversed(chain): | for x in reversed(chain): | ||||
descendant_fees += mempool[x]['fee'] | descendant_fees += mempool[x]['fee'] | ||||
assert_equal(mempool[x]['fees']['descendant'], | assert_equal(mempool[x]['fees']['descendant'], | ||||
descendant_fees + Decimal('0.00001')) | descendant_fees + Decimal('0.00001')) | ||||
assert_equal(mempool[x]['descendantfees'], | assert_equal(mempool[x]['descendantfees'], | ||||
descendant_fees * COIN + 1000) | descendant_fees * COIN + 1000) | ||||
# Adding one more transaction on to the chain should fail. | # Adding one more transaction on to the chain should fail. | ||||
assert_raises_rpc_error(-26, "too-long-mempool-chain", | assert_raises_rpc_error(-26, "too-long-mempool-chain", | ||||
self.chain_transaction, self.nodes[0], txid, vout, value, fee, 1) | self.chain_transaction, self.nodes[0], txid, vout, value, fee, 1) | ||||
# Check that prioritising a tx before it's added to the mempool works | # Check that prioritising a tx before it's added to the mempool works | ||||
# First clear the mempool by mining a block. | # First clear the mempool by mining a block. | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
assert_equal(len(self.nodes[0].getrawmempool()), 0) | assert_equal(len(self.nodes[0].getrawmempool()), 0) | ||||
# Prioritise a transaction that has been mined, then add it back to the | # Prioritise a transaction that has been mined, then add it back to the | ||||
# mempool by using invalidateblock. | # mempool by using invalidateblock. | ||||
self.nodes[0].prioritisetransaction(chain[-1], 0, 2000) | self.nodes[0].prioritisetransaction(chain[-1], 2000) | ||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) | self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) | ||||
# Keep node1's tip synced with node0 | # Keep node1's tip synced with node0 | ||||
self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash()) | self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash()) | ||||
# Now check that the transaction is in the mempool, with the right modified fee | # Now check that the transaction is in the mempool, with the right modified fee | ||||
mempool = self.nodes[0].getrawmempool(True) | mempool = self.nodes[0].getrawmempool(True) | ||||
descendant_fees = 0 | descendant_fees = 0 | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |