mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
66e77f7879
7b3c9e4ee8feb552dc0fc4347db2d06e60894a9f Make explicit the node param in init_wallet() (lsilva01) Pull request description: This PR changes the definition of `def init_wallet(self, i)` to `def init_wallet(self, *, node)` to make the node parameter explicit, as suggested in https://github.com/bitcoin/bitcoin/pull/22794#discussion_r713287448 . ACKs for top commit: stratospher: tested ACK 7b3c9e4. Tree-SHA512: 2ef036f4c2110b2f7dc893dc6eea8faa0a18edd7f8f59b25460a6c544df7238175ddd6a0d766e2bb206326b1c9afc84238c75613a0f01eeda89a8ccb7d86a4f1
58 lines
1.8 KiB
Python
Executable File
58 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test error messages for 'getaddressinfo' and 'validateaddress' RPC commands."""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
from test_framework.util import (
|
|
assert_equal,
|
|
assert_raises_rpc_error,
|
|
)
|
|
|
|
|
|
BASE58_VALID = 'yjQ5gLvGRtmq1cwc4kePLCrzQ8GVCh9Gaz'
|
|
BASE58_INVALID_PREFIX = 'XpG61qAVhdyN7AqVZQsHfJL7AEk4dPVinc'
|
|
|
|
INVALID_ADDRESS = 'asfah14i8fajz0123f'
|
|
|
|
class InvalidAddressErrorMessageTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 1
|
|
|
|
def test_validateaddress(self):
|
|
node = self.nodes[0]
|
|
|
|
# Base58
|
|
info = node.validateaddress(BASE58_INVALID_PREFIX)
|
|
assert not info['isvalid']
|
|
assert_equal(info['error'], 'Invalid prefix for Base58-encoded address')
|
|
|
|
info = node.validateaddress(BASE58_VALID)
|
|
assert info['isvalid']
|
|
assert 'error' not in info
|
|
|
|
# Invalid address format
|
|
info = node.validateaddress(INVALID_ADDRESS)
|
|
assert not info['isvalid']
|
|
assert_equal(info['error'], 'Invalid address format')
|
|
|
|
def test_getaddressinfo(self):
|
|
node = self.nodes[0]
|
|
|
|
assert_raises_rpc_error(-5, "Invalid prefix for Base58-encoded address", node.getaddressinfo, BASE58_INVALID_PREFIX)
|
|
assert_raises_rpc_error(-5, "Invalid address format", node.getaddressinfo, INVALID_ADDRESS)
|
|
|
|
def run_test(self):
|
|
self.test_validateaddress()
|
|
|
|
if self.is_wallet_compiled():
|
|
self.init_wallet(node=0)
|
|
self.test_getaddressinfo()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
InvalidAddressErrorMessageTest().main()
|