mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 19:43:13 +02:00
[tests] Move bech32 unit tests to test framework
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Reference implementation for Bech32 and segwit addresses."""
|
||||
|
||||
import unittest
|
||||
|
||||
CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
|
||||
|
||||
@@ -105,3 +105,17 @@ def encode(hrp, witver, witprog):
|
||||
if decode(hrp, ret) == (None, None):
|
||||
return None
|
||||
return ret
|
||||
|
||||
class TestFrameworkScript(unittest.TestCase):
|
||||
def test_segwit_encode_decode(self):
|
||||
def test_python_bech32(addr):
|
||||
hrp = addr[:4]
|
||||
self.assertEqual(hrp, "bcrt")
|
||||
(witver, witprog) = decode(hrp, addr)
|
||||
self.assertEqual(encode(hrp, witver, witprog), addr)
|
||||
|
||||
# P2WPKH
|
||||
test_python_bech32('bcrt1qthmht0k2qnh3wy7336z05lu2km7emzfpm3wg46')
|
||||
# P2WSH
|
||||
test_python_bech32('bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj')
|
||||
test_python_bech32('bcrt1qft5p2uhsdcdc3l2ua4ap5qqfg4pjaqlp250x7us7a8qqhrxrxfsqseac85')
|
||||
|
Reference in New Issue
Block a user