|
2 | 2 | import unittest |
3 | 3 | from binascii import unhexlify |
4 | 4 |
|
5 | | -from pybitmessage import addresses |
| 5 | +from pybitmessage import addresses, highlevelcrypto |
6 | 6 |
|
7 | 7 | from .samples import ( |
8 | 8 | sample_address, sample_daddr3_512, sample_daddr4_512, |
9 | 9 | sample_deterministic_addr4, sample_deterministic_addr3, |
10 | | - sample_deterministic_ripe, sample_ripe) |
| 10 | + sample_deterministic_ripe, sample_ripe, |
| 11 | + sample_privsigningkey_wif, sample_privencryptionkey_wif, |
| 12 | + sample_wif_privsigningkey, sample_wif_privencryptionkey) |
11 | 13 |
|
12 | 14 | sample_addr3 = sample_deterministic_addr3.split('-')[1] |
13 | 15 | sample_addr4 = sample_deterministic_addr4.split('-')[1] |
@@ -59,3 +61,26 @@ def test_base58(self): |
59 | 61 | sample_addr4, addresses.encodeBase58(sample_daddr4_512)) |
60 | 62 | self.assertEqual( |
61 | 63 | sample_addr3, addresses.encodeBase58(sample_daddr3_512)) |
| 64 | + |
| 65 | + def test_wif(self): |
| 66 | + """Decode WIFs of [chan] bitmessage and check the keys""" |
| 67 | + self.assertEqual( |
| 68 | + sample_wif_privsigningkey, |
| 69 | + highlevelcrypto.decodeWalletImportFormat( |
| 70 | + sample_privsigningkey_wif)) |
| 71 | + self.assertEqual( |
| 72 | + sample_wif_privencryptionkey, |
| 73 | + highlevelcrypto.decodeWalletImportFormat( |
| 74 | + sample_privencryptionkey_wif)) |
| 75 | + self.assertEqual( |
| 76 | + sample_privsigningkey_wif, |
| 77 | + highlevelcrypto.encodeWalletImportFormat( |
| 78 | + sample_wif_privsigningkey)) |
| 79 | + self.assertEqual( |
| 80 | + sample_privencryptionkey_wif, |
| 81 | + highlevelcrypto.encodeWalletImportFormat( |
| 82 | + sample_wif_privencryptionkey)) |
| 83 | + |
| 84 | + with self.assertRaises(ValueError): |
| 85 | + highlevelcrypto.decodeWalletImportFormat( |
| 86 | + sample_privencryptionkey_wif[:-2]) |
0 commit comments