From 07f815c28bfa418dd7f6802046f1ed410b876b99 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 29 Jul 2021 16:33:33 +0300 Subject: [PATCH] Add a test for WIF decoding --- src/tests/samples.py | 7 +++++++ src/tests/test_addresses.py | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/tests/samples.py b/src/tests/samples.py index fd7393e1..57510c3f 100644 --- a/src/tests/samples.py +++ b/src/tests/samples.py @@ -56,3 +56,10 @@ sample_sig = unhexlify( sample_sig_sha1 = unhexlify( '304502203b50123af78b4e40f5f819ae5b8786f48826e56d0f3e65744708a493f5b65de1' '0221009ddce2981ea143c0ac70404a535327e774adce8eebbae2d35104f1d326255f9a') + + +# [chan] bitmessage +sample_wif_privsigningkey = unhexlify( + b'a2e8b841a531c1c558ee0680c396789c7a2ea3ac4795ae3f000caf9fe367d144') +sample_wif_privencryptionkey = unhexlify( + b'114ec0e2dca24a826a0eed064b0405b0ac148abc3b1d52729697f4d7b873fdc6') diff --git a/src/tests/test_addresses.py b/src/tests/test_addresses.py index 8f9c283d..43b4884f 100644 --- a/src/tests/test_addresses.py +++ b/src/tests/test_addresses.py @@ -2,12 +2,13 @@ import unittest from binascii import unhexlify -from pybitmessage import addresses +from pybitmessage import addresses, shared from .samples import ( sample_address, sample_daddr3_512, sample_daddr4_512, sample_deterministic_addr4, sample_deterministic_addr3, - sample_deterministic_ripe, sample_ripe) + sample_deterministic_ripe, sample_ripe, + sample_wif_privsigningkey, sample_wif_privencryptionkey) sample_addr3 = sample_deterministic_addr3.split('-')[1] sample_addr4 = sample_deterministic_addr4.split('-')[1] @@ -59,3 +60,14 @@ class TestAddresses(unittest.TestCase): sample_addr4, addresses.encodeBase58(sample_daddr4_512)) self.assertEqual( sample_addr3, addresses.encodeBase58(sample_daddr3_512)) + + def test_wif(self): + """Decode WIFs of [chan] bitmessage and check the keys""" + self.assertEqual( + sample_wif_privsigningkey, + shared.decodeWalletImportFormat( + b'5K42shDERM5g7Kbi3JT5vsAWpXMqRhWZpX835M2pdSoqQQpJMYm')) + self.assertEqual( + sample_wif_privencryptionkey, + shared.decodeWalletImportFormat( + b'5HwugVWm31gnxtoYcvcK7oywH2ezYTh6Y4tzRxsndAeMi6NHqpA'))