diff options
author | whythat <whythat@protonmail.com> | 2018-10-12 11:57:22 +0300 |
---|---|---|
committer | whythat <whythat@protonmail.com> | 2018-10-13 19:37:44 +0300 |
commit | 14a06525b2ed41d9a549e744019c06afeef9b0c5 (patch) | |
tree | 8b44c9da22c55913313aabd0605a69df82d3ba33 /test | |
parent | 93d1aa9abc4402715f781db2bc26bdde4447e951 (diff) |
tests: add test for 'getaddressinfo' RPC result 'ischange' field
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/wallet_basic.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 8bbff7f7ef..09e03fa787 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -479,7 +479,7 @@ class WalletTest(BitcoinTestFramework): # Verify nothing new in wallet assert_equal(total_txs, len(self.nodes[0].listtransactions("*", 99999))) - # Test getaddressinfo. Note that these addresses are taken from disablewallet.py + # Test getaddressinfo on external address. Note that these addresses are taken from disablewallet.py assert_raises_rpc_error(-5, "Invalid address", self.nodes[0].getaddressinfo, "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy") address_info = self.nodes[0].getaddressinfo("mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ") assert_equal(address_info['address'], "mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ") @@ -487,6 +487,22 @@ class WalletTest(BitcoinTestFramework): assert not address_info["ismine"] assert not address_info["iswatchonly"] assert not address_info["isscript"] + assert not address_info["ischange"] + + # Test getaddressinfo 'ischange' field on change address. + self.nodes[0].generate(1) + destination = self.nodes[1].getnewaddress() + txid = self.nodes[0].sendtoaddress(destination, 0.123) + tx = self.nodes[0].decoderawtransaction(self.nodes[0].getrawtransaction(txid)) + output_addresses = [vout['scriptPubKey']['addresses'][0] for vout in tx["vout"]] + assert len(output_addresses) > 1 + for address in output_addresses: + ischange = self.nodes[0].getaddressinfo(address)['ischange'] + assert_equal(ischange, address != destination) + if ischange: + change = address + self.nodes[0].setlabel(change, 'foobar') + assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False) if __name__ == '__main__': WalletTest().main() |