aboutsummaryrefslogtreecommitdiff
path: root/src/test/bip32_tests.cpp
diff options
context:
space:
mode:
authorlangerhans <[email protected]>2019-06-09 19:49:48 +0200
committerlangerhans <[email protected]>2019-06-09 19:51:03 +0200
commitd278efaccdc45e7155147d2c86a50f193eafdc07 (patch)
tree05cf92afa059fafff80e460c1619edd5bec231b3 /src/test/bip32_tests.cpp
parentRevert "Change fPIE to fPIC (#1420)" (#1447) (diff)
parentMark 1.14 ready for release (diff)
downloaddiscoin-d278efaccdc45e7155147d2c86a50f193eafdc07.tar.xz
discoin-d278efaccdc45e7155147d2c86a50f193eafdc07.zip
Merge branch '1.14-branding'
Diffstat (limited to 'src/test/bip32_tests.cpp')
-rw-r--r--src/test/bip32_tests.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp
index b16309166..7087b184c 100644
--- a/src/test/bip32_tests.cpp
+++ b/src/test/bip32_tests.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2013 The Bitcoin Core developers
+// Copyright (c) 2013-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -88,12 +88,23 @@ void RunTest(const TestVector &test) {
unsigned char data[74];
key.Encode(data);
pubkey.Encode(data);
+
// Test private key
CBitcoinExtKey b58key; b58key.SetKey(key);
BOOST_CHECK(b58key.ToString() == derive.prv);
+
+ CBitcoinExtKey b58keyDecodeCheck(derive.prv);
+ CExtKey checkKey = b58keyDecodeCheck.GetKey();
+ assert(checkKey == key); //ensure a base58 decoded key also matches
+
// Test public key
CBitcoinExtPubKey b58pubkey; b58pubkey.SetKey(pubkey);
BOOST_CHECK(b58pubkey.ToString() == derive.pub);
+
+ CBitcoinExtPubKey b58PubkeyDecodeCheck(derive.pub);
+ CExtPubKey checkPubKey = b58PubkeyDecodeCheck.GetKey();
+ assert(checkPubKey == pubkey); //ensure a base58 decoded pubkey also matches
+
// Derive new keys
CExtKey keyNew;
BOOST_CHECK(key.Derive(keyNew, derive.nChild));
@@ -106,6 +117,22 @@ void RunTest(const TestVector &test) {
}
key = keyNew;
pubkey = pubkeyNew;
+
+ CDataStream ssPub(SER_DISK, CLIENT_VERSION);
+ ssPub << pubkeyNew;
+ BOOST_CHECK(ssPub.size() == 75);
+
+ CDataStream ssPriv(SER_DISK, CLIENT_VERSION);
+ ssPriv << keyNew;
+ BOOST_CHECK(ssPriv.size() == 75);
+
+ CExtPubKey pubCheck;
+ CExtKey privCheck;
+ ssPub >> pubCheck;
+ ssPriv >> privCheck;
+
+ BOOST_CHECK(pubCheck == pubkeyNew);
+ BOOST_CHECK(privCheck == keyNew);
}
}