Changeset View
Changeset View
Standalone View
Standalone View
src/test/key_tests.cpp
Show All 26 Lines | static const std::string strSecret2C = | ||||
"L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g"; | "L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g"; | ||||
static const std::string addr1 = "1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"; | static const std::string addr1 = "1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"; | ||||
static const std::string addr2 = "1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ"; | static const std::string addr2 = "1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ"; | ||||
static const std::string addr1C = "1NoJrossxPBKfCHuJXT4HadJrXRE9Fxiqs"; | static const std::string addr1C = "1NoJrossxPBKfCHuJXT4HadJrXRE9Fxiqs"; | ||||
static const std::string addr2C = "1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs"; | static const std::string addr2C = "1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs"; | ||||
static const std::string strAddressBad = "1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF"; | static const std::string strAddressBad = "1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF"; | ||||
#ifdef KEY_TESTS_DUMPINFO | |||||
void dumpKeyInfo(uint256 privkey) { | |||||
CKey key; | |||||
key.resize(32); | |||||
memcpy(&secret[0], &privkey, 32); | |||||
std::vector<uint8_t> sec; | |||||
sec.resize(32); | |||||
memcpy(&sec[0], &secret[0], 32); | |||||
printf(" * secret (hex): %s\n", HexStr(sec).c_str()); | |||||
for (int nCompressed = 0; nCompressed < 2; nCompressed++) { | |||||
bool fCompressed = nCompressed == 1; | |||||
printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed"); | |||||
CBitcoinSecret bsecret; | |||||
bsecret.SetSecret(secret, fCompressed); | |||||
printf(" * secret (base58): %s\n", bsecret.ToString().c_str()); | |||||
CKey key; | |||||
key.SetSecret(secret, fCompressed); | |||||
std::vector<uint8_t> vchPubKey = key.GetPubKey(); | |||||
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str()); | |||||
printf(" * address (base58): %s\n", | |||||
CBitcoinAddress(vchPubKey).ToString().c_str()); | |||||
} | |||||
} | |||||
#endif | |||||
BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup) | ||||
BOOST_AUTO_TEST_CASE(key_test1) { | BOOST_AUTO_TEST_CASE(key_test1) { | ||||
CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1; | CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1; | ||||
BOOST_CHECK(bsecret1.SetString(strSecret1)); | BOOST_CHECK(bsecret1.SetString(strSecret1)); | ||||
BOOST_CHECK(bsecret2.SetString(strSecret2)); | BOOST_CHECK(bsecret2.SetString(strSecret2)); | ||||
BOOST_CHECK(bsecret1C.SetString(strSecret1C)); | BOOST_CHECK(bsecret1C.SetString(strSecret1C)); | ||||
BOOST_CHECK(bsecret2C.SetString(strSecret2C)); | BOOST_CHECK(bsecret2C.SetString(strSecret2C)); | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |