Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
for address in output_addresses: | for address in output_addresses: | ||||
ischange = self.nodes[0].getaddressinfo(address)['ischange'] | ischange = self.nodes[0].getaddressinfo(address)['ischange'] | ||||
assert_equal(ischange, address != destination) | assert_equal(ischange, address != destination) | ||||
if ischange: | if ischange: | ||||
change = address | change = address | ||||
self.nodes[0].setlabel(change, 'foobar') | self.nodes[0].setlabel(change, 'foobar') | ||||
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False) | assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False) | ||||
# Test "decoded" field value in gettransaction response | # Test gettransaction response with different arguments. | ||||
self.log.info("Testing gettransaction decoding...") | self.log.info( | ||||
tx = self.nodes[0].gettransaction(txid=txid, decode=True) | "Testing gettransaction response with different arguments...") | ||||
self.nodes[0].setlabel(change, 'baz') | |||||
baz = self.nodes[0].listtransactions(label="baz", count=1)[0] | |||||
expected_receive_vout = {"label": "baz", | |||||
"address": baz["address"], | |||||
"amount": baz["amount"], | |||||
"category": baz["category"], | |||||
"vout": baz["vout"]} | |||||
expected_fields = frozenset({'amount', | |||||
'confirmations', | |||||
'details', | |||||
'fee', | |||||
'hex', | |||||
'time', | |||||
'timereceived', | |||||
'trusted', | |||||
'txid', | |||||
'walletconflicts'}) | |||||
verbose_field = "decoded" | |||||
expected_verbose_fields = expected_fields | {verbose_field} | |||||
self.log.debug("Testing gettransaction response without verbose") | |||||
tx = self.nodes[0].gettransaction(txid=txid) | |||||
assert_equal(set([*tx]), expected_fields) | |||||
assert_array_result( | |||||
tx["details"], { | |||||
"category": "receive"}, expected_receive_vout) | |||||
self.log.debug( | |||||
"Testing gettransaction response with verbose set to False") | |||||
tx = self.nodes[0].gettransaction(txid=txid, verbose=False) | |||||
assert_equal(set([*tx]), expected_fields) | |||||
assert_array_result( | |||||
tx["details"], { | |||||
"category": "receive"}, expected_receive_vout) | |||||
self.log.debug( | |||||
"Testing gettransaction response with verbose set to True") | |||||
tx = self.nodes[0].gettransaction(txid=txid, verbose=True) | |||||
assert_equal(set([*tx]), expected_verbose_fields) | |||||
assert_array_result( | |||||
tx["details"], { | |||||
"category": "receive"}, expected_receive_vout) | |||||
assert_equal( | assert_equal( | ||||
tx["decoded"], | tx[verbose_field], | ||||
self.nodes[0].decoderawtransaction( | self.nodes[0].decoderawtransaction( | ||||
tx["hex"])) | tx["hex"])) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
WalletTest().main() | WalletTest().main() |