Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_listreceivedby.py
Show All 14 Lines | |||||
) | ) | ||||
class ReceivedByTest(BitcoinTestFramework): | class ReceivedByTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [['-deprecatedrpc=accounts']] * 2 | self.extra_args = [['-deprecatedrpc=accounts']] * 2 | ||||
def import_deterministic_coinbase_privkeys(self): | |||||
assert_equal(0, len(self.nodes[1].listreceivedbyaddress( | |||||
minconf=0, include_empty=True, include_watchonly=True))) | |||||
super().import_deterministic_coinbase_privkeys() | |||||
self.num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress( | |||||
minconf=0, include_empty=True, include_watchonly=True)) | |||||
def run_test(self): | def run_test(self): | ||||
# Generate block to get out of IBD | # Generate block to get out of IBD | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
self.log.info("listreceivedbyaddress Test") | self.log.info("listreceivedbyaddress Test") | ||||
# Send from node 0 to 1 | # Send from node 0 to 1 | ||||
Show All 34 Lines | def run_test(self): | ||||
minconf=0, include_empty=True, include_watchonly=True, address_filter=addr) | minconf=0, include_empty=True, include_watchonly=True, address_filter=addr) | ||||
assert_array_result(res, {"address": addr}, expected) | assert_array_result(res, {"address": addr}, expected) | ||||
assert_equal(len(res), 1) | assert_equal(len(res), 1) | ||||
# Error on invalid address | # Error on invalid address | ||||
assert_raises_rpc_error(-4, "address_filter parameter was invalid", | 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") | self.nodes[1].listreceivedbyaddress, minconf=0, include_empty=True, include_watchonly=True, address_filter="bamboozling") | ||||
# Another address receive money | # Another address receive money | ||||
res = self.nodes[1].listreceivedbyaddress(0, True, True) | res = self.nodes[1].listreceivedbyaddress(0, True, True) | ||||
assert_equal(len(res), 2) # Right now 2 entries | # Right now 2 entries | ||||
assert_equal(len(res), 2 + self.num_cb_reward_addresses) | |||||
other_addr = self.nodes[1].getnewaddress() | other_addr = self.nodes[1].getnewaddress() | ||||
txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1) | txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# Same test as above should still pass | # Same test as above should still pass | ||||
expected = {"address": addr, "label": "", "amount": Decimal( | expected = {"address": addr, "label": "", "amount": Decimal( | ||||
"0.1"), "confirmations": 11, "txids": [txid, ]} | "0.1"), "confirmations": 11, "txids": [txid, ]} | ||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, addr) | res = self.nodes[1].listreceivedbyaddress(0, True, True, addr) | ||||
assert_array_result(res, {"address": addr}, expected) | assert_array_result(res, {"address": addr}, expected) | ||||
assert_equal(len(res), 1) | assert_equal(len(res), 1) | ||||
# Same test as above but with other_addr should still pass | # Same test as above but with other_addr should still pass | ||||
expected = {"address": other_addr, "label": "", "amount": Decimal( | expected = {"address": other_addr, "label": "", "amount": Decimal( | ||||
"0.1"), "confirmations": 1, "txids": [txid2, ]} | "0.1"), "confirmations": 1, "txids": [txid2, ]} | ||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr) | res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr) | ||||
assert_array_result(res, {"address": other_addr}, expected) | assert_array_result(res, {"address": other_addr}, expected) | ||||
assert_equal(len(res), 1) | assert_equal(len(res), 1) | ||||
# Should be two entries though without filter | # Should be two entries though without filter | ||||
res = self.nodes[1].listreceivedbyaddress(0, True, True) | res = self.nodes[1].listreceivedbyaddress(0, True, True) | ||||
assert_equal(len(res), 3) # Became 3 entries | # Became 3 entries | ||||
assert_equal(len(res), 3 + self.num_cb_reward_addresses) | |||||
# Not on random addr | # Not on random addr | ||||
# note on node[0]! just a random addr | # note on node[0]! just a random addr | ||||
other_addr = self.nodes[0].getnewaddress() | other_addr = self.nodes[0].getnewaddress() | ||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr) | res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr) | ||||
assert_equal(len(res), 0) | assert_equal(len(res), 0) | ||||
self.log.info("getreceivedbyaddress Test") | self.log.info("getreceivedbyaddress Test") | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |