Add blech32 roundtrip test for python implementation

This commit is contained in:
Gregory Sanders 2019-09-13 10:54:43 -04:00 committed by Dmitry Petukhov
parent 32564b0a99
commit 522a147be7
No known key found for this signature in database
GPG key ID: 2301D26BDC15160D

View file

@ -28,6 +28,11 @@ from test_framework.util import (
import os
import re
from test_framework.liquid_addr import (
encode,
decode,
)
class CTTest (BitcoinTestFramework):
def set_test_params(self):
@ -104,6 +109,15 @@ class CTTest (BitcoinTestFramework):
print("Testing wallet secret recovery")
self.test_wallet_recovery()
print("Test blech32 python roundtrip")
# blech/bech are aliased, both are blech32
for addrtype in ["bech32", "blech32"]:
addr_to_rt = self.nodes[0].getnewaddress("", addrtype)
hrp = addr_to_rt[:2]
assert_equal(hrp, "el")
(witver, witprog) = decode(hrp, addr_to_rt)
assert_equal(encode(hrp, witver, witprog), addr_to_rt)
# Test that "blech32" gives a blinded segwit address.
blech32_addr = self.nodes[0].getnewaddress("", "blech32")
blech32_addr_info = self.nodes[0].getaddressinfo(blech32_addr)