aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_address_types.py
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2019-09-13 11:11:17 -0400
committerGregory Sanders <gsanders87@gmail.com>2019-09-15 15:22:22 -0400
commitae0add8dfe23310e10f18732dbd54360ce405b9b (patch)
tree99136088e0d7ee93ed161d0854f1a0639aa930da /test/functional/wallet_address_types.py
parentfb4f5beb6ede4aadeaff779cd67a0f6665419488 (diff)
downloadbitcoin-ae0add8dfe23310e10f18732dbd54360ce405b9b.tar.xz
Add python bech32 impl round-trip test
Diffstat (limited to 'test/functional/wallet_address_types.py')
-rwxr-xr-xtest/functional/wallet_address_types.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py
index 4e4ed8f26b..f8318555b1 100755
--- a/test/functional/wallet_address_types.py
+++ b/test/functional/wallet_address_types.py
@@ -64,7 +64,10 @@ from test_framework.util import (
assert_raises_rpc_error,
connect_nodes_bi,
)
-
+from test_framework.segwit_addr import (
+ encode,
+ decode,
+)
class AddressTypeTest(BitcoinTestFramework):
def set_test_params(self):
@@ -97,6 +100,13 @@ class AddressTypeTest(BitcoinTestFramework):
else:
return [self.nodes[i].getunconfirmedbalance() for i in range(4)]
+ # Quick test of python bech32 implementation
+ def test_python_bech32(self, addr):
+ hrp = addr[:4]
+ assert_equal(hrp, "bcrt")
+ (witver, witprog) = decode(hrp, addr)
+ assert_equal(encode(hrp, witver, witprog), addr)
+
def test_address(self, node, address, multisig, typ):
"""Run sanity checks on an address."""
info = self.nodes[node].getaddressinfo(address)
@@ -121,6 +131,7 @@ class AddressTypeTest(BitcoinTestFramework):
assert_equal(info['witness_version'], 0)
assert_equal(len(info['witness_program']), 40)
assert 'pubkey' in info
+ self.test_python_bech32(info["address"])
elif typ == 'legacy':
# P2SH-multisig
assert info['isscript']
@@ -146,6 +157,7 @@ class AddressTypeTest(BitcoinTestFramework):
assert_equal(info['witness_version'], 0)
assert_equal(len(info['witness_program']), 64)
assert 'pubkeys' in info
+ self.test_python_bech32(info["address"])
else:
# Unknown type
assert False