Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_packages.py
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | def chain_transaction(self, node, parent_txid, vout, | ||||
fulltx = node.getrawtransaction(txid, 1) | fulltx = node.getrawtransaction(txid, 1) | ||||
# make sure we didn't generate a change output | # make sure we didn't generate a change output | ||||
assert len(fulltx['vout']) == num_outputs | assert len(fulltx['vout']) == num_outputs | ||||
return (txid, send_value) | return (txid, send_value) | ||||
def run_test(self): | def run_test(self): | ||||
# Mine some blocks and have them mature. | # Mine some blocks and have them mature. | ||||
# keep track of invs | # keep track of invs | ||||
self.nodes[0].add_p2p_connection(P2PTxInvStore()) | peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) | ||||
self.nodes[0].generate(101) | self.nodes[0].generate(101) | ||||
utxo = self.nodes[0].listunspent(10) | utxo = self.nodes[0].listunspent(10) | ||||
txid = utxo[0]['txid'] | txid = utxo[0]['txid'] | ||||
vout = utxo[0]['vout'] | vout = utxo[0]['vout'] | ||||
value = utxo[0]['amount'] | value = utxo[0]['amount'] | ||||
fee = Decimal("100") | fee = Decimal("100") | ||||
# MAX_ANCESTORS transactions off a confirmed tx should be fine | # MAX_ANCESTORS transactions off a confirmed tx should be fine | ||||
chain = [] | chain = [] | ||||
for _ in range(MAX_ANCESTORS): | for _ in range(MAX_ANCESTORS): | ||||
(txid, sent_value) = self.chain_transaction( | (txid, sent_value) = self.chain_transaction( | ||||
self.nodes[0], txid, 0, value, fee, 1) | self.nodes[0], txid, 0, value, fee, 1) | ||||
value = sent_value | value = sent_value | ||||
chain.append(txid) | chain.append(txid) | ||||
# Wait until mempool transactions have passed initial broadcast | # Wait until mempool transactions have passed initial broadcast | ||||
# (sent inv and received getdata) | # (sent inv and received getdata) | ||||
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if | # Otherwise, getrawmempool may be inconsistent with getmempoolentry if | ||||
# unbroadcast changes in between | # unbroadcast changes in between | ||||
self.nodes[0].p2p.wait_for_broadcast(chain) | peer_inv_store.wait_for_broadcast(chain) | ||||
# Check mempool has MAX_ANCESTORS transactions in it, and descendant and ancestor | # Check mempool has MAX_ANCESTORS transactions in it, and descendant and ancestor | ||||
# count and fees should look correct | # count and fees should look correct | ||||
mempool = self.nodes[0].getrawmempool(True) | mempool = self.nodes[0].getrawmempool(True) | ||||
assert_equal(len(mempool), MAX_ANCESTORS) | assert_equal(len(mempool), MAX_ANCESTORS) | ||||
descendant_count = 1 | descendant_count = 1 | ||||
descendant_fees = 0 | descendant_fees = 0 | ||||
descendant_size = 0 | descendant_size = 0 | ||||
▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines |