Skip to content

Commit 8d2af54

Browse files
committed
extend bip32 tests to cover Base58c/CExtKey decode
1 parent 7cb1f9f commit 8d2af54

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/bip32_tests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,23 @@ void RunTest(const TestVector &test) {
8888
unsigned char data[74];
8989
key.Encode(data);
9090
pubkey.Encode(data);
91+
9192
// Test private key
9293
CBitcoinExtKey b58key; b58key.SetKey(key);
9394
BOOST_CHECK(b58key.ToString() == derive.prv);
95+
96+
CBitcoinExtKey b58keyDecodeCheck(derive.prv);
97+
CExtKey checkKey = b58keyDecodeCheck.GetKey();
98+
assert(checkKey == key); //ensure a base58 decoded key also matches
99+
94100
// Test public key
95101
CBitcoinExtPubKey b58pubkey; b58pubkey.SetKey(pubkey);
96102
BOOST_CHECK(b58pubkey.ToString() == derive.pub);
103+
104+
CBitcoinExtPubKey b58PubkeyDecodeCheck(derive.pub);
105+
CExtPubKey checkPubKey = b58PubkeyDecodeCheck.GetKey();
106+
assert(checkPubKey == pubkey); //ensure a base58 decoded pubkey also matches
107+
97108
// Derive new keys
98109
CExtKey keyNew;
99110
BOOST_CHECK(key.Derive(keyNew, derive.nChild));

0 commit comments

Comments
 (0)