MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/wallet_listreceivedby.py:28–283  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26 self.skip_if_no_cli()
27
28 def run_test(self):
29 # Generate block to get out of IBD
30 self.generate(self.nodes[0], 1)
31
32 # save the number of coinbase reward addresses so far
33 num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True))
34
35 self.log.info("listreceivedbyaddress Test")
36
37 # Send from node 0 to 1
38 addr = self.nodes[1].getnewaddress()
39 txid = self.nodes[0].sendtoaddress(addr, 0.1)
40 self.sync_all()
41
42 # Check not listed in listreceivedbyaddress because has 0 confirmations
43 assert_array_result(self.nodes[1].listreceivedbyaddress(),
44 {"address": addr},
45 {},
46 True)
47 # Bury Tx under 10 block so it will be returned by listreceivedbyaddress
48 self.generate(self.nodes[1], 10)
49 assert_array_result(self.nodes[1].listreceivedbyaddress(),
50 {"address": addr},
51 {"address": addr, "label": "", "amount": {"bitcoin": Decimal("0.1")}, "confirmations": 10, "txids": [txid, ]})
52 # With min confidence < 10
53 assert_array_result(self.nodes[1].listreceivedbyaddress(5),
54 {"address": addr},
55 {"address": addr, "label": "", "amount": {"bitcoin": Decimal("0.1")}, "confirmations": 10, "txids": [txid, ]})
56 # With min confidence > 10, should not find Tx
57 assert_array_result(self.nodes[1].listreceivedbyaddress(11), {"address": addr}, {}, True)
58
59 # Empty Tx
60 empty_addr = self.nodes[1].getnewaddress()
61 assert_array_result(self.nodes[1].listreceivedbyaddress(0, True),
62 {"address": empty_addr},
63 {"address": empty_addr, "label": "", "amount": {"bitcoin": 0}, "confirmations": 0, "txids": []})
64
65 # Test Address filtering
66 # Only on addr
67 expected = {"address": addr, "label": "", "amount": {"bitcoin": Decimal("0.1")}, "confirmations": 10, "txids": [txid, ]}
68 res = self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True, address_filter=addr)
69 assert_array_result(res, {"address": addr}, expected)
70 assert_equal(len(res), 1)
71 # Test for regression on CLI calls with address string (#14173)
72 cli_res = self.nodes[1].cli.listreceivedbyaddress(0, True, True, addr)
73 assert_array_result(cli_res, {"address": addr}, expected)
74 assert_equal(len(cli_res), 1)
75 # Error on invalid address
76 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")
77 # Another address receive money
78 res = self.nodes[1].listreceivedbyaddress(0, True, True)
79 assert_equal(len(res), 2 + num_cb_reward_addresses) # Right now 2 entries
80 other_addr = self.nodes[1].getnewaddress()
81 txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1)
82 self.generate(self.nodes[0], 1)
83 # Same test as above should still pass
84 expected = {"address": addr, "label": "", "amount": {"bitcoin": Decimal("0.1")}, "confirmations": 11, "txids": [txid, ]}
85 res = self.nodes[1].listreceivedbyaddress(0, True, True, addr)

Callers

nothing calls this directly

Calls 8

assert_array_resultFunction · 0.90
assert_equalFunction · 0.90
assert_raises_rpc_errorFunction · 0.90
test_addressFunction · 0.90
infoMethod · 0.80
generateMethod · 0.45
sync_allMethod · 0.45
generatetoaddressMethod · 0.45

Tested by

no test coverage detected