Skip to content

Commit be9f014

Browse files
committed
WIP: test, automatically abandon txs during startup
1 parent eeaa308 commit be9f014

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

test/functional/wallet_reorgsrestore.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def test_automatic_abandon_during_startup(self):
3838
# part of the best chain.
3939
# TODO: need to also verify that any descendant of this coinbase transaction is also marked as abandoned..
4040
# 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)
4146
##########################################################################################################
4247
# Sync nodes for the coming test and assert all are at the same block
4348
for i, j in [(0, 1), (1, 2), (2, 0)]:
@@ -56,12 +61,16 @@ def test_automatic_abandon_during_startup(self):
5661
self.generatetoaddress(self.nodes[0], 1, wallet0.getnewaddress(), sync_fun=self.no_op)
5762
node0_coinbase_tx_hash = wallet0.getblock(wallet0.getbestblockhash(), verbose=1)['tx'][0]
5863

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+
5969
# Verify balance is greater than 0.
6070
wallet0.syncwithvalidationinterfacequeue()
61-
assert(wallet0.getbalances()['mine']['immature'] > 0)
71+
assert(wallet0.getbalances()['mine']['trusted'] > 0)
6272

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.
6574
self.nodes[1].createwallet(wallet_name="w1", load_on_startup=True)
6675
wallet1 = self.nodes[1].get_wallet_rpc("w1")
6776
self.generatetoaddress(self.nodes[1], 1, wallet1.getnewaddress(), sync_fun=self.no_op)
@@ -87,10 +96,10 @@ def test_automatic_abandon_during_startup(self):
8796

8897
# Verify the coinbase tx was marked as abandoned and balance correctly computed
8998
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)
91102

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
94103

95104
def run_test(self):
96105
# Send a tx from which to conflict outputs later

0 commit comments

Comments
 (0)