Skip to content

Commit 77650cc

Browse files
jonasschnellilaanwj
authored andcommitted
add -walletbroadcast=0 rpc test
1 parent 6f25262 commit 77650cc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

qa/rpc-tests/wallet.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,47 @@ def run_test (self):
150150
sync_mempools(self.nodes)
151151

152152
assert(txid1 in self.nodes[3].getrawmempool())
153+
154+
155+
#do some -walletbroadcast tests
156+
stop_nodes(self.nodes)
157+
wait_bitcoinds()
158+
self.nodes = start_nodes(3, self.options.tmpdir, [["-walletbroadcast=0"],["-walletbroadcast=0"],["-walletbroadcast=0"]])
159+
connect_nodes_bi(self.nodes,0,1)
160+
connect_nodes_bi(self.nodes,1,2)
161+
connect_nodes_bi(self.nodes,0,2)
162+
self.sync_all()
153163

164+
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
165+
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
166+
self.nodes[1].setgenerate(True, 1) #mine a block, tx should not be in there
167+
self.sync_all()
168+
assert_equal(self.nodes[2].getbalance(), Decimal('59.99800000')); #should not be changed because tx was not broadcasted
169+
170+
#now broadcast from another node, mine a block, sync, and check the balance
171+
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
172+
self.nodes[1].setgenerate(True, 1)
173+
self.sync_all()
174+
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
175+
assert_equal(self.nodes[2].getbalance(), Decimal('61.99800000')); #should not be
176+
177+
#create another tx
178+
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
179+
180+
#restart the nodes with -walletbroadcast=1
181+
stop_nodes(self.nodes)
182+
wait_bitcoinds()
183+
self.nodes = start_nodes(3, self.options.tmpdir)
184+
connect_nodes_bi(self.nodes,0,1)
185+
connect_nodes_bi(self.nodes,1,2)
186+
connect_nodes_bi(self.nodes,0,2)
187+
sync_blocks(self.nodes)
188+
189+
self.nodes[0].setgenerate(True, 1)
190+
sync_blocks(self.nodes)
191+
192+
#tx should be added to balance because after restarting the nodes tx should be broadcastet
193+
assert_equal(self.nodes[2].getbalance(), Decimal('63.99800000')); #should not be
194+
154195
if __name__ == '__main__':
155196
WalletTest ().main ()

0 commit comments

Comments
 (0)