@@ -51,12 +51,17 @@ def run_test(self):
51
51
txid = utxo [0 ]['txid' ]
52
52
vout = utxo [0 ]['vout' ]
53
53
value = utxo [0 ]['amount' ]
54
+ assert 'ancestorcount' not in utxo [0 ]
55
+ assert 'ancestorsize' not in utxo [0 ]
56
+ assert 'ancestorfees' not in utxo [0 ]
54
57
55
58
fee = Decimal ("0.0001" )
56
59
# MAX_ANCESTORS transactions off a confirmed tx should be fine
57
60
chain = []
58
61
witness_chain = []
59
- for _ in range (MAX_ANCESTORS ):
62
+ ancestor_vsize = 0
63
+ ancestor_fees = Decimal (0 )
64
+ for i in range (MAX_ANCESTORS ):
60
65
(txid , sent_value ) = chain_transaction (self .nodes [0 ], [txid ], [0 ], value , fee , 1 )
61
66
value = sent_value
62
67
chain .append (txid )
@@ -65,6 +70,15 @@ def run_test(self):
65
70
witnesstx = self .nodes [0 ].decoderawtransaction (fulltx , True )
66
71
witness_chain .append (witnesstx ['hash' ])
67
72
73
+ # Check that listunspent ancestor{count, size, fees} yield the correct results
74
+ wallet_unspent = self .nodes [0 ].listunspent (minconf = 0 )
75
+ this_unspent = next (utxo_info for utxo_info in wallet_unspent if utxo_info ['txid' ] == txid )
76
+ assert_equal (this_unspent ['ancestorcount' ], i + 1 )
77
+ ancestor_vsize += self .nodes [0 ].getrawtransaction (txid = txid , verbose = True )['vsize' ]
78
+ assert_equal (this_unspent ['ancestorsize' ], ancestor_vsize )
79
+ ancestor_fees -= self .nodes [0 ].gettransaction (txid = txid )['fee' ]
80
+ assert_equal (this_unspent ['ancestorfees' ], ancestor_fees * COIN )
81
+
68
82
# Wait until mempool transactions have passed initial broadcast (sent inv and received getdata)
69
83
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between
70
84
peer_inv_store .wait_for_broadcast (witness_chain )
@@ -77,9 +91,9 @@ def run_test(self):
77
91
descendant_fees = 0
78
92
descendant_vsize = 0
79
93
80
- ancestor_vsize = sum ([mempool [tx ]['vsize' ] for tx in mempool ])
94
+ assert_equal ( ancestor_vsize , sum ([mempool [tx ]['vsize' ] for tx in mempool ]) )
81
95
ancestor_count = MAX_ANCESTORS
82
- ancestor_fees = sum ([mempool [tx ]['fee' ] for tx in mempool ])
96
+ assert_equal ( ancestor_fees , sum ([mempool [tx ]['fee' ] for tx in mempool ]) )
83
97
84
98
descendants = []
85
99
ancestors = list (chain )
0 commit comments