diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2020-06-18 18:25:04 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2021-09-16 20:34:49 +0000 |
commit | 0be2f17ef5649c2d77efbbbdd9222332b2ebf0d2 (patch) | |
tree | a63ac643c99e4add3d9aee29900eff4ce9ad5864 | |
parent | 6966e80f453c46d5d0a923118205f19ac2f4e336 (diff) | |
download | bitcoin-0be2f17ef5649c2d77efbbbdd9222332b2ebf0d2.tar.xz |
QA: Add tests for listunspent ancestor{count,size,fees} to mempool_packages
-rwxr-xr-x | test/functional/mempool_packages.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index 5fc3ec23ae..0bbe4525a8 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -51,12 +51,17 @@ class MempoolPackagesTest(BitcoinTestFramework): txid = utxo[0]['txid'] vout = utxo[0]['vout'] 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") # MAX_ANCESTORS transactions off a confirmed tx should be fine 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) value = sent_value chain.append(txid) @@ -65,6 +70,15 @@ class MempoolPackagesTest(BitcoinTestFramework): witnesstx = self.nodes[0].decoderawtransaction(fulltx, True) 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) # Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between peer_inv_store.wait_for_broadcast(witness_chain) @@ -77,9 +91,9 @@ class MempoolPackagesTest(BitcoinTestFramework): descendant_fees = 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_fees = sum([mempool[tx]['fee'] for tx in mempool]) + assert_equal(ancestor_fees, sum([mempool[tx]['fee'] for tx in mempool])) descendants = [] ancestors = list(chain) |