Fix other potential race conditions similar to ref #1597 in RPC tests.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
f0f838f081
commit
deba66ca55
|
@ -51,6 +51,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
assert_equal(walletinfo['immature_balance'], 0)
|
assert_equal(walletinfo['immature_balance'], 0)
|
||||||
|
|
||||||
# Have node0 mine a block, thus it will collect its own fee.
|
# Have node0 mine a block, thus it will collect its own fee.
|
||||||
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
self.nodes[1].sendrawtransaction(txns_to_send[2]["hex"], True)
|
self.nodes[1].sendrawtransaction(txns_to_send[2]["hex"], True)
|
||||||
|
|
||||||
# Have node1 mine a block to confirm transactions:
|
# Have node1 mine a block to confirm transactions:
|
||||||
|
self.sync_all()
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -99,6 +101,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
address = self.nodes[0].getnewaddress("")
|
address = self.nodes[0].getnewaddress("")
|
||||||
self.nodes[2].settxfee(Decimal('0.001'))
|
self.nodes[2].settxfee(Decimal('0.001'))
|
||||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('39.99900000'))
|
assert_equal(self.nodes[2].getbalance(), Decimal('39.99900000'))
|
||||||
|
@ -108,6 +111,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
|
|
||||||
# Send 10 BTC with subtract fee from amount
|
# Send 10 BTC with subtract fee from amount
|
||||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
|
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('29.99900000'))
|
assert_equal(self.nodes[2].getbalance(), Decimal('29.99900000'))
|
||||||
|
@ -117,6 +121,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
|
|
||||||
# Sendmany 10 BTC
|
# Sendmany 10 BTC
|
||||||
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [])
|
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [])
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('19.99800000'))
|
assert_equal(self.nodes[2].getbalance(), Decimal('19.99800000'))
|
||||||
|
@ -126,6 +131,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
|
|
||||||
# Sendmany 10 BTC with subtract fee from amount
|
# Sendmany 10 BTC with subtract fee from amount
|
||||||
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [address])
|
txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [address])
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000'))
|
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000'))
|
||||||
|
@ -190,6 +196,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
|
|
||||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
|
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
|
||||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||||
|
self.sync_all()
|
||||||
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
||||||
self.sync_all()
|
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
|
||||||
|
@ -197,6 +204,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
|
|
||||||
#now broadcast from another node, mine a block, sync, and check the balance
|
#now broadcast from another node, mine a block, sync, and check the balance
|
||||||
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
||||||
|
self.sync_all()
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||||
|
@ -225,6 +233,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
# send from node 0 to node 2 taddr
|
# send from node 0 to node 2 taddr
|
||||||
mytaddr = self.nodes[2].getnewaddress();
|
mytaddr = self.nodes[2].getnewaddress();
|
||||||
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
||||||
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -258,6 +267,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
break
|
break
|
||||||
|
|
||||||
assert_equal("success", status)
|
assert_equal("success", status)
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -304,6 +314,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
break
|
break
|
||||||
|
|
||||||
assert_equal("success", status)
|
assert_equal("success", status)
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
mytxid = results[0]["result"]["txid"]
|
mytxid = results[0]["result"]["txid"]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
mytxid = results[0]["result"]["txid"]
|
mytxid = results[0]["result"]["txid"]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -110,6 +112,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
mytxid = results[0]["result"]["txid"]
|
mytxid = results[0]["result"]["txid"]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
@ -150,6 +153,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
mytxid = results[0]["result"]["txid"]
|
mytxid = results[0]["result"]["txid"]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.sync_all()
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue