aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_address_types.py
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2019-02-06 18:08:21 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2019-02-15 22:36:05 -0800
commit3b40bff9880e9ae2817136b7d14989afccfc1937 (patch)
tree65325ad0dbdda14e32704dfff400196aa13d04b8 /test/functional/wallet_address_types.py
parent743c2f461c0e7c58b1e5c6ddfeaf4f0ff6e6ca85 (diff)
downloadbitcoin-3b40bff9880e9ae2817136b7d14989afccfc1937.tar.xz
Descriptor checksum
Diffstat (limited to 'test/functional/wallet_address_types.py')
-rwxr-xr-xtest/functional/wallet_address_types.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py
index bafa556aad..027229111e 100755
--- a/test/functional/wallet_address_types.py
+++ b/test/functional/wallet_address_types.py
@@ -54,6 +54,10 @@ from decimal import Decimal
import itertools
from test_framework.test_framework import BitcoinTestFramework
+from test_framework.descriptors import (
+ descsum_create,
+ descsum_check,
+)
from test_framework.util import (
assert_equal,
assert_greater_than,
@@ -167,24 +171,29 @@ class AddressTypeTest(BitcoinTestFramework):
assert_equal(deriv['path'][0], 'm')
key_descs[deriv['pubkey']] = '[' + deriv['master_fingerprint'] + deriv['path'][1:] + ']' + deriv['pubkey']
+ # Verify the descriptor checksum against the Python implementation
+ assert(descsum_check(info['desc']))
+ # Verify that stripping the checksum and recreating it using Python roundtrips
+ assert(info['desc'] == descsum_create(info['desc'][:-9]))
+
if not multisig and typ == 'legacy':
# P2PKH
- assert_equal(info['desc'], "pkh(%s)" % key_descs[info['pubkey']])
+ assert_equal(info['desc'], descsum_create("pkh(%s)" % key_descs[info['pubkey']]))
elif not multisig and typ == 'p2sh-segwit':
# P2SH-P2WPKH
- assert_equal(info['desc'], "sh(wpkh(%s))" % key_descs[info['pubkey']])
+ assert_equal(info['desc'], descsum_create("sh(wpkh(%s))" % key_descs[info['pubkey']]))
elif not multisig and typ == 'bech32':
# P2WPKH
- assert_equal(info['desc'], "wpkh(%s)" % key_descs[info['pubkey']])
+ assert_equal(info['desc'], descsum_create("wpkh(%s)" % key_descs[info['pubkey']]))
elif typ == 'legacy':
# P2SH-multisig
- assert_equal(info['desc'], "sh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]]))
+ assert_equal(info['desc'], descsum_create("sh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]])))
elif typ == 'p2sh-segwit':
# P2SH-P2WSH-multisig
- assert_equal(info['desc'], "sh(wsh(multi(2,%s,%s)))" % (key_descs[info['embedded']['pubkeys'][0]], key_descs[info['embedded']['pubkeys'][1]]))
+ assert_equal(info['desc'], descsum_create("sh(wsh(multi(2,%s,%s)))" % (key_descs[info['embedded']['pubkeys'][0]], key_descs[info['embedded']['pubkeys'][1]])))
elif typ == 'bech32':
# P2WSH-multisig
- assert_equal(info['desc'], "wsh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]]))
+ assert_equal(info['desc'], descsum_create("wsh(multi(2,%s,%s))" % (key_descs[info['pubkeys'][0]], key_descs[info['pubkeys'][1]])))
else:
# Unknown type
assert(False)