mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
QA: Add tests for listunspent ancestor{count,size,fees} to mempool_packages
This commit is contained in:
parent
6966e80f45
commit
0be2f17ef5
1 changed files with 17 additions and 3 deletions
|
@ -51,12 +51,17 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
txid = utxo[0]['txid']
|
txid = utxo[0]['txid']
|
||||||
vout = utxo[0]['vout']
|
vout = utxo[0]['vout']
|
||||||
value = utxo[0]['amount']
|
value = utxo[0]['amount']
|
||||||
|
assert 'ancestorcount' not in utxo[0]
|
||||||
|
assert 'ancestorsize' not in utxo[0]
|
||||||
|
assert 'ancestorfees' not in utxo[0]
|
||||||
|
|
||||||
fee = Decimal("0.0001")
|
fee = Decimal("0.0001")
|
||||||
# MAX_ANCESTORS transactions off a confirmed tx should be fine
|
# MAX_ANCESTORS transactions off a confirmed tx should be fine
|
||||||
chain = []
|
chain = []
|
||||||
witness_chain = []
|
witness_chain = []
|
||||||
for _ in range(MAX_ANCESTORS):
|
ancestor_vsize = 0
|
||||||
|
ancestor_fees = Decimal(0)
|
||||||
|
for i in range(MAX_ANCESTORS):
|
||||||
(txid, sent_value) = chain_transaction(self.nodes[0], [txid], [0], value, fee, 1)
|
(txid, sent_value) = chain_transaction(self.nodes[0], [txid], [0], value, fee, 1)
|
||||||
value = sent_value
|
value = sent_value
|
||||||
chain.append(txid)
|
chain.append(txid)
|
||||||
|
@ -65,6 +70,15 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
witnesstx = self.nodes[0].decoderawtransaction(fulltx, True)
|
witnesstx = self.nodes[0].decoderawtransaction(fulltx, True)
|
||||||
witness_chain.append(witnesstx['hash'])
|
witness_chain.append(witnesstx['hash'])
|
||||||
|
|
||||||
|
# Check that listunspent ancestor{count, size, fees} yield the correct results
|
||||||
|
wallet_unspent = self.nodes[0].listunspent(minconf=0)
|
||||||
|
this_unspent = next(utxo_info for utxo_info in wallet_unspent if utxo_info['txid'] == txid)
|
||||||
|
assert_equal(this_unspent['ancestorcount'], i + 1)
|
||||||
|
ancestor_vsize += self.nodes[0].getrawtransaction(txid=txid, verbose=True)['vsize']
|
||||||
|
assert_equal(this_unspent['ancestorsize'], ancestor_vsize)
|
||||||
|
ancestor_fees -= self.nodes[0].gettransaction(txid=txid)['fee']
|
||||||
|
assert_equal(this_unspent['ancestorfees'], ancestor_fees * COIN)
|
||||||
|
|
||||||
# Wait until mempool transactions have passed initial broadcast (sent inv and received getdata)
|
# Wait until mempool transactions have passed initial broadcast (sent inv and received getdata)
|
||||||
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between
|
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between
|
||||||
peer_inv_store.wait_for_broadcast(witness_chain)
|
peer_inv_store.wait_for_broadcast(witness_chain)
|
||||||
|
@ -77,9 +91,9 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
descendant_fees = 0
|
descendant_fees = 0
|
||||||
descendant_vsize = 0
|
descendant_vsize = 0
|
||||||
|
|
||||||
ancestor_vsize = sum([mempool[tx]['vsize'] for tx in mempool])
|
assert_equal(ancestor_vsize, sum([mempool[tx]['vsize'] for tx in mempool]))
|
||||||
ancestor_count = MAX_ANCESTORS
|
ancestor_count = MAX_ANCESTORS
|
||||||
ancestor_fees = sum([mempool[tx]['fee'] for tx in mempool])
|
assert_equal(ancestor_fees, sum([mempool[tx]['fee'] for tx in mempool]))
|
||||||
|
|
||||||
descendants = []
|
descendants = []
|
||||||
ancestors = list(chain)
|
ancestors = list(chain)
|
||||||
|
|
Loading…
Add table
Reference in a new issue