diff options
author | Daniel Kraft <d@domob.eu> | 2014-10-20 14:14:04 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2014-10-24 08:53:04 +0200 |
commit | dcb98466b4f8193fc28656d17b2317f21665fa3a (patch) | |
tree | af414ee4e69a16a680ec364ab51c2ac5b7f549c0 /qa/rpc-tests/receivedby.py | |
parent | 3552d4b859d56726cd25baa6f1e5988050bdad33 (diff) |
Extend getchaintips RPC test.
Add the capability to simulate network splits to the RPC test framework
and use it to do more extensive testing of 'getchaintips'.
Diffstat (limited to 'qa/rpc-tests/receivedby.py')
-rwxr-xr-x | qa/rpc-tests/receivedby.py | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index 61f5e0452b..7170255242 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -54,36 +54,36 @@ def check_array_result(object_array, to_match, expected, should_not_find = False class ReceivedByTest(BitcoinTestFramework): - def run_test(self, nodes): + def run_test(self): ''' listreceivedbyaddress Test ''' # Send from node 0 to 1 - addr = nodes[1].getnewaddress() - txid = nodes[0].sendtoaddress(addr, 0.1) - sync_mempools(nodes) + addr = self.nodes[1].getnewaddress() + txid = self.nodes[0].sendtoaddress(addr, 0.1) + self.sync_all() #Check not listed in listreceivedbyaddress because has 0 confirmations - check_array_result(nodes[1].listreceivedbyaddress(), + check_array_result(self.nodes[1].listreceivedbyaddress(), {"address":addr}, { }, True) #Bury Tx under 10 block so it will be returned by listreceivedbyaddress - nodes[1].setgenerate(True, 10) - sync_blocks(nodes) - check_array_result(nodes[1].listreceivedbyaddress(), + self.nodes[1].setgenerate(True, 10) + self.sync_all() + check_array_result(self.nodes[1].listreceivedbyaddress(), {"address":addr}, {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]}) #With min confidence < 10 - check_array_result(nodes[1].listreceivedbyaddress(5), + check_array_result(self.nodes[1].listreceivedbyaddress(5), {"address":addr}, {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]}) #With min confidence > 10, should not find Tx - check_array_result(nodes[1].listreceivedbyaddress(11),{"address":addr},{ },True) + check_array_result(self.nodes[1].listreceivedbyaddress(11),{"address":addr},{ },True) #Empty Tx - addr = nodes[1].getnewaddress() - check_array_result(nodes[1].listreceivedbyaddress(0,True), + addr = self.nodes[1].getnewaddress() + check_array_result(self.nodes[1].listreceivedbyaddress(0,True), {"address":addr}, {"address":addr, "account":"", "amount":0, "confirmations":0, "txids":[]}) @@ -91,24 +91,24 @@ class ReceivedByTest(BitcoinTestFramework): getreceivedbyaddress Test ''' # Send from node 0 to 1 - addr = nodes[1].getnewaddress() - txid = nodes[0].sendtoaddress(addr, 0.1) - sync_mempools(nodes) + addr = self.nodes[1].getnewaddress() + txid = self.nodes[0].sendtoaddress(addr, 0.1) + self.sync_all() #Check balance is 0 because of 0 confirmations - balance = nodes[1].getreceivedbyaddress(addr) + balance = self.nodes[1].getreceivedbyaddress(addr) if balance != Decimal("0.0"): raise AssertionError("Wrong balance returned by getreceivedbyaddress, %0.2f"%(balance)) #Check balance is 0.1 - balance = nodes[1].getreceivedbyaddress(addr,0) + balance = self.nodes[1].getreceivedbyaddress(addr,0) if balance != Decimal("0.1"): raise AssertionError("Wrong balance returned by getreceivedbyaddress, %0.2f"%(balance)) #Bury Tx under 10 block so it will be returned by the default getreceivedbyaddress - nodes[1].setgenerate(True, 10) - sync_blocks(nodes) - balance = nodes[1].getreceivedbyaddress(addr) + self.nodes[1].setgenerate(True, 10) + self.sync_all() + balance = self.nodes[1].getreceivedbyaddress(addr) if balance != Decimal("0.1"): raise AssertionError("Wrong balance returned by getreceivedbyaddress, %0.2f"%(balance)) @@ -116,40 +116,40 @@ class ReceivedByTest(BitcoinTestFramework): listreceivedbyaccount + getreceivedbyaccount Test ''' #set pre-state - addrArr = nodes[1].getnewaddress() - account = nodes[1].getaccount(addrArr) - received_by_account_json = get_sub_array_from_array(nodes[1].listreceivedbyaccount(),{"account":account}) + addrArr = self.nodes[1].getnewaddress() + account = self.nodes[1].getaccount(addrArr) + received_by_account_json = get_sub_array_from_array(self.nodes[1].listreceivedbyaccount(),{"account":account}) if len(received_by_account_json) == 0: raise AssertionError("No accounts found in node") - balance_by_account = rec_by_accountArr = nodes[1].getreceivedbyaccount(account) + balance_by_account = rec_by_accountArr = self.nodes[1].getreceivedbyaccount(account) - txid = nodes[0].sendtoaddress(addr, 0.1) + txid = self.nodes[0].sendtoaddress(addr, 0.1) # listreceivedbyaccount should return received_by_account_json because of 0 confirmations - check_array_result(nodes[1].listreceivedbyaccount(), + check_array_result(self.nodes[1].listreceivedbyaccount(), {"account":account}, received_by_account_json) # getreceivedbyaddress should return same balance because of 0 confirmations - balance = nodes[1].getreceivedbyaccount(account) + balance = self.nodes[1].getreceivedbyaccount(account) if balance != balance_by_account: raise AssertionError("Wrong balance returned by getreceivedbyaccount, %0.2f"%(balance)) - nodes[1].setgenerate(True, 10) - sync_blocks(nodes) + self.nodes[1].setgenerate(True, 10) + self.sync_all() # listreceivedbyaccount should return updated account balance - check_array_result(nodes[1].listreceivedbyaccount(), + check_array_result(self.nodes[1].listreceivedbyaccount(), {"account":account}, {"account":received_by_account_json["account"], "amount":(received_by_account_json["amount"] + Decimal("0.1"))}) # getreceivedbyaddress should return updates balance - balance = nodes[1].getreceivedbyaccount(account) + balance = self.nodes[1].getreceivedbyaccount(account) if balance != balance_by_account + Decimal("0.1"): raise AssertionError("Wrong balance returned by getreceivedbyaccount, %0.2f"%(balance)) #Create a new account named "mynewaccount" that has a 0 balance - nodes[1].getaccountaddress("mynewaccount") - received_by_account_json = get_sub_array_from_array(nodes[1].listreceivedbyaccount(0,True),{"account":"mynewaccount"}) + self.nodes[1].getaccountaddress("mynewaccount") + received_by_account_json = get_sub_array_from_array(self.nodes[1].listreceivedbyaccount(0,True),{"account":"mynewaccount"}) if len(received_by_account_json) == 0: raise AssertionError("No accounts found in node") @@ -158,7 +158,7 @@ class ReceivedByTest(BitcoinTestFramework): raise AssertionError("Wrong balance returned by listreceivedbyaccount, %0.2f"%(received_by_account_json["amount"])) # Test getreceivedbyaccount for 0 amount accounts - balance = nodes[1].getreceivedbyaccount("mynewaccount") + balance = self.nodes[1].getreceivedbyaccount("mynewaccount") if balance != Decimal("0.0"): raise AssertionError("Wrong balance returned by getreceivedbyaccount, %0.2f"%(balance)) |