Skip to content

Commit

Permalink
Auto merge of zcash#1599 - daira:1597.fix-other-potential-race-condit…
Browse files Browse the repository at this point in the history
…ions, r=daira

Fix other potential race conditions similar to ref zcash#1597 in RPC tests.

Signed-off-by: Daira Hopwood <[email protected]>
  • Loading branch information
zkbot committed Oct 22, 2016
2 parents 7ccbcca + deba66c commit 48888b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qa/rpc-tests/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def run_test (self):
assert_equal(walletinfo['immature_balance'], 0)

# Have node0 mine a block, thus it will collect its own fee.
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

Expand Down Expand Up @@ -87,6 +88,7 @@ def run_test (self):
self.nodes[1].sendrawtransaction(txns_to_send[2]["hex"], True)

# Have node1 mine a block to confirm transactions:
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()

Expand All @@ -99,6 +101,7 @@ def run_test (self):
address = self.nodes[0].getnewaddress("")
self.nodes[2].settxfee(Decimal('0.001'))
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[2].getbalance(), Decimal('39.99900000'))
Expand All @@ -108,6 +111,7 @@ def run_test (self):

# Send 10 BTC with subtract fee from amount
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[2].getbalance(), Decimal('29.99900000'))
Expand All @@ -117,6 +121,7 @@ def run_test (self):

# Sendmany 10 BTC
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [])
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[2].getbalance(), Decimal('19.99800000'))
Expand All @@ -126,6 +131,7 @@ def run_test (self):

# Sendmany 10 BTC with subtract fee from amount
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [address])
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000'))
Expand Down Expand Up @@ -190,13 +196,15 @@ def run_test (self):

txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
self.sync_all()
self.nodes[1].generate(1) #mine a block, tx should not be in there
self.sync_all()
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000')); #should not be changed because tx was not broadcasted
assert_equal(self.nodes[2].getbalance("*"), Decimal('9.99800000')); #should not be changed because tx was not broadcasted

#now broadcast from another node, mine a block, sync, and check the balance
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
Expand Down Expand Up @@ -225,6 +233,7 @@ def run_test (self):
# send from node 0 to node 2 taddr
mytaddr = self.nodes[2].getnewaddress();
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

Expand Down Expand Up @@ -258,6 +267,7 @@ def run_test (self):
break

assert_equal("success", status)
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()

Expand Down Expand Up @@ -304,6 +314,7 @@ def run_test (self):
break

assert_equal("success", status)
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()

Expand Down
4 changes: 4 additions & 0 deletions qa/rpc-tests/wallet_nullifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def run_test (self):
mytxid = results[0]["result"]["txid"]
break

self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

Expand Down Expand Up @@ -79,6 +80,7 @@ def run_test (self):
mytxid = results[0]["result"]["txid"]
break

self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

Expand Down Expand Up @@ -110,6 +112,7 @@ def run_test (self):
mytxid = results[0]["result"]["txid"]
break

self.sync_all()
self.nodes[2].generate(1)
self.sync_all()

Expand Down Expand Up @@ -150,6 +153,7 @@ def run_test (self):
mytxid = results[0]["result"]["txid"]
break

self.sync_all()
self.nodes[1].generate(1)
self.sync_all()

Expand Down

0 comments on commit 48888b6

Please sign in to comment.