@@ -38,6 +38,11 @@ def test_automatic_abandon_during_startup(self):
38
38
# part of the best chain.
39
39
# TODO: need to also verify that any descendant of this coinbase transaction is also marked as abandoned..
40
40
# TODO: The code to fix this is to copy paste AddToWallet into LoadToWallet
41
+ # TODO: hmm, thinking further about what was doing this morning..
42
+ # After chain replacement, because the coinbase tx is not marked abandoned during startup, their descendants
43
+ # will not be marked as abandoned neither.. so the wallet will continue broadcasting them over the network.
44
+ # Which will fill all the connected peers mempool for no reason because the node will not broadcast the parent
45
+ # (because it is a coinbase tx)
41
46
##########################################################################################################
42
47
# Sync nodes for the coming test and assert all are at the same block
43
48
for i , j in [(0 , 1 ), (1 , 2 ), (2 , 0 )]:
@@ -56,12 +61,16 @@ def test_automatic_abandon_during_startup(self):
56
61
self .generatetoaddress (self .nodes [0 ], 1 , wallet0 .getnewaddress (), sync_fun = self .no_op )
57
62
node0_coinbase_tx_hash = wallet0 .getblock (wallet0 .getbestblockhash (), verbose = 1 )['tx' ][0 ]
58
63
64
+ # Mine 100 blocks on top to mature the coinbase and create a descendant
65
+ self .generate (self .nodes [0 ], 101 , sync_fun = self .no_op )
66
+ # Make descendant, send-to-self
67
+ descendant_tx_id = wallet0 .sendtoaddress (wallet0 .getnewaddress (), 1 )
68
+
59
69
# Verify balance is greater than 0.
60
70
wallet0 .syncwithvalidationinterfacequeue ()
61
- assert (wallet0 .getbalances ()['mine' ]['immature ' ] > 0 )
71
+ assert (wallet0 .getbalances ()['mine' ]['trusted ' ] > 0 )
62
72
63
- # Now create another block in node1 at the same tip as the one we just created for node0
64
- # This will be used to replace the node0 chain later.
73
+ # Now create a fork in node1. This will be used to replace node0's chain later.
65
74
self .nodes [1 ].createwallet (wallet_name = "w1" , load_on_startup = True )
66
75
wallet1 = self .nodes [1 ].get_wallet_rpc ("w1" )
67
76
self .generatetoaddress (self .nodes [1 ], 1 , wallet1 .getnewaddress (), sync_fun = self .no_op )
@@ -87,10 +96,10 @@ def test_automatic_abandon_during_startup(self):
87
96
88
97
# Verify the coinbase tx was marked as abandoned and balance correctly computed
89
98
assert_equal (wallet0 .gettransaction (node0_coinbase_tx_hash )['details' ][0 ]['abandoned' ], True )
90
- assert (wallet0 .getbalances ()['mine' ]['immature' ] == 0 )
99
+ assert (wallet0 .getbalances ()['mine' ]['trusted' ] == 0 )
100
+ # Verify the coinbase descendant was also marked as abandoned
101
+ assert_equal (wallet0 .gettransaction (descendant_tx_id )['details' ][0 ]['abandoned' ], True )
91
102
92
- # TODO: need to also verify that any descendant of this coinbase transaction is also marked as abandoned..
93
- # TODO: The code to fix this is to copy paste AddToWallet into LoadToWallet
94
103
95
104
def run_test (self ):
96
105
# Send a tx from which to conflict outputs later
0 commit comments