mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 18:02:44 +02:00
Merge #9991: listreceivedbyaddress Filter Address
f08761371
Add tests of listreceivedbyaddress address filtering (Jeremy Rubin)8ee08120d
Add address filtering to listreceivedbyaddress (Jeremy Rubin) Pull request description: Supersede https://github.com/bitcoin/bitcoin/pull/9503 created by @JeremyRubin , I will maintain it. Tree-SHA512: 2accaed493b7e1c2eb5cb5270180f100f8c718b6585b9574f294191c318dc622a79e42ac185300f291f82d3b2a6f1c00850b6b17e4ff2dbab94d71df695acbfe
This commit is contained in:
@@ -45,10 +45,44 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(11), {"address": addr}, {}, True)
|
||||
|
||||
# Empty Tx
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
empty_addr = self.nodes[1].getnewaddress()
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(0, True),
|
||||
{"address": addr},
|
||||
{"address": addr, "account": "", "amount": 0, "confirmations": 0, "txids": []})
|
||||
{"address": empty_addr},
|
||||
{"address": empty_addr, "account": "", "amount": 0, "confirmations": 0, "txids": []})
|
||||
|
||||
#Test Address filtering
|
||||
#Only on addr
|
||||
expected = {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True, address_filter=addr)
|
||||
assert_array_result(res, {"address":addr}, expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Error on invalid address
|
||||
assert_raises_rpc_error(-4, "address_filter parameter was invalid", self.nodes[1].listreceivedbyaddress, minconf=0, include_empty=True, include_watchonly=True, address_filter="bamboozling")
|
||||
#Another address receive money
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
||||
assert_equal(len(res), 2) #Right now 2 entries
|
||||
other_addr = self.nodes[1].getnewaddress()
|
||||
txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
#Same test as above should still pass
|
||||
expected = {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":11, "txids":[txid,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, addr)
|
||||
assert_array_result(res, {"address":addr}, expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Same test as above but with other_addr should still pass
|
||||
expected = {"address":other_addr, "account":"", "amount":Decimal("0.1"), "confirmations":1, "txids":[txid2,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr)
|
||||
assert_array_result(res, {"address":other_addr}, expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Should be two entries though without filter
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
||||
assert_equal(len(res), 3) #Became 3 entries
|
||||
|
||||
#Not on random addr
|
||||
other_addr = self.nodes[0].getnewaddress() # note on node[0]! just a random addr
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr)
|
||||
assert_equal(len(res), 0)
|
||||
|
||||
self.log.info("getreceivedbyaddress Test")
|
||||
|
||||
|
Reference in New Issue
Block a user