Merge bitcoin/bitcoin#34188: test: Add multiple transactions and error handling tests for getreceivedbyaddress
d45ec3fba9test: Add getreceivedbyaddress coverage to wallet_listreceivedby (b-l-u-e) Pull request description: This PR adds comprehensive functional test coverage for the `getreceivedbyaddress` RPC method. ACKs for top commit: maflcko: lgtm ACKd45ec3fba9fjahr: reACKd45ec3fba9achow101: ACKd45ec3fba9rkrux: lgtm ACKd45ec3fba9Tree-SHA512: e7f024297c18b2e11da108d9588bbf96089dce24e2fdee255dbd2f754f21ec63cb3cefa6d92b621b5ab66d18fe29523b87d14ceba38a83afa4c85eb5944a0fb3
This commit is contained in:
1 file changed
+12
-1
@@ -124,6 +124,17 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||||||
# Trying to getreceivedby for an address the wallet doesn't own should return an error
|
# Trying to getreceivedby for an address the wallet doesn't own should return an error
|
||||||
assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
|
assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
|
||||||
|
|
||||||
|
# Test multiple transactions to the same address
|
||||||
|
addr_with_multiple_txs = self.nodes[1].getnewaddress()
|
||||||
|
self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.1"))
|
||||||
|
self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.2"))
|
||||||
|
self.generate(self.nodes[0], 1)
|
||||||
|
balance = self.nodes[1].getreceivedbyaddress(addr_with_multiple_txs)
|
||||||
|
assert_equal(balance, Decimal("0.3"))
|
||||||
|
|
||||||
|
# Test invalid address format error
|
||||||
|
assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[1].getreceivedbyaddress, "invalid_address")
|
||||||
|
|
||||||
self.log.info("listreceivedbylabel + getreceivedbylabel Test")
|
self.log.info("listreceivedbylabel + getreceivedbylabel Test")
|
||||||
|
|
||||||
# set pre-state
|
# set pre-state
|
||||||
@@ -144,7 +155,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||||||
{"label": label},
|
{"label": label},
|
||||||
received_by_label_json)
|
received_by_label_json)
|
||||||
|
|
||||||
# getreceivedbyaddress should return same balance because of 0 confirmations
|
# getreceivedbylabel should return same balance because of 0 confirmations
|
||||||
balance = self.nodes[1].getreceivedbylabel(label)
|
balance = self.nodes[1].getreceivedbylabel(label)
|
||||||
assert_equal(balance, balance_by_label)
|
assert_equal(balance, balance_by_label)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user