Browse Source

Fixed unit tests.

cn
Jianping Wu 6 years ago
parent
commit
72d45d6a69
  1. 30
      src/chainparams.cpp
  2. 4
      src/chainparams.h
  3. 8
      src/coins.cpp
  4. 4
      src/coins.h
  5. 4
      src/keva/main.cpp
  6. 4
      src/keva/main.h
  7. 4
      src/test/bloom_tests.cpp
  8. 88
      src/test/key_tests.cpp
  9. 4
      src/test/main_tests.cpp
  10. 5
      src/wallet/rpcwallet.cpp
  11. 8
      src/wallet/test/wallet_tests.cpp
  12. 2
      src/wallet/wallet.cpp

30
src/chainparams.cpp

@ -149,7 +149,7 @@ public:
}; };
} }
int DefaultCheckNameDB() const int DefaultCheckKevaDB() const
{ {
return -1; return -1;
} }
@ -240,7 +240,7 @@ public:
} }
int DefaultCheckNameDB() const int DefaultCheckKevaDB() const
{ {
return -1; return -1;
} }
@ -260,8 +260,8 @@ public:
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests) consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests) consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 3.5 * 24 * 60 * 60; // two weeks consensus.nPowTargetTimespan = 1; // 1 second
consensus.nPowTargetSpacing = 2.5 * 60; consensus.nPowTargetSpacing = 1; // 1 second
consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true; consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
@ -289,24 +289,10 @@ public:
nDefaultPort = 19444; nDefaultPort = 19444;
nPruneAfterHeight = 1000; nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1296688602, 0, 0x207fffff, 1, 50 * COIN); genesis = CreateGenesisBlock(1296688602, 1, 0x207fffff, 1, 50 * COIN);
//JW remove the following code!
arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits);
uint256 hashGenesisBlock = uint256S("0x01");
if (false && genesis.GetHash() != hashGenesisBlock) {
printf("recalculating params for mainnet.\n");
printf("old mainnet genesis nonce: %d\n", genesis.nNonce);
printf("old mainnet genesis hash: %s\n", hashGenesisBlock.ToString().c_str());
// deliberately empty for loop finds nonce value.
for(genesis.nNonce = 0; hashTarget < UintToArith256(genesis.GetPoWHash()); genesis.nNonce++){}
printf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("new mainnet genesis nonce: %d\n", genesis.nNonce);
printf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str());
}
consensus.hashGenesisBlock = genesis.GetHash(); consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9")); assert(consensus.hashGenesisBlock == uint256S("0x8353937c85572e556dbec10555b846ddd1a812ab328c9089527f88081e1b5a11"));
assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); assert(genesis.hashMerkleRoot == uint256S("0x13ec98c3307b8e6b67b91c605c7347916a99f9dfde7b5d88365aaef322192314"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds. vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds. vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
@ -338,7 +324,7 @@ public:
bech32_hrp = "rkva"; bech32_hrp = "rkva";
} }
int DefaultCheckNameDB() const int DefaultCheckKevaDB() const
{ {
return 0; return 0;
} }

4
src/chainparams.h

@ -60,8 +60,8 @@ public:
const CBlock& GenesisBlock() const { return genesis; } const CBlock& GenesisBlock() const { return genesis; }
/** Default value for -checkmempool and -checkblockindex argument */ /** Default value for -checkmempool and -checkblockindex argument */
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
/** Default value for -checknamedb argument */ /** Default value for -checkkevadb argument */
virtual int DefaultCheckNameDB() const = 0; virtual int DefaultCheckKevaDB() const = 0;
/** Policy: Filter transactions that do not match well-defined patterns */ /** Policy: Filter transactions that do not match well-defined patterns */
bool RequireStandard() const { return fRequireStandard; } bool RequireStandard() const { return fRequireStandard; }
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }

8
src/coins.cpp

@ -16,7 +16,11 @@ bool CCoinsView::GetNamesForHeight(unsigned nHeight, std::set<valtype>& names) c
CKevaIterator* CCoinsView::IterateKeys(const valtype& nameSpace) const { assert (false); } CKevaIterator* CCoinsView::IterateKeys(const valtype& nameSpace) const { assert (false); }
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) { return false; } bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) { return false; }
CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; } CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; }
bool CCoinsView::ValidateNameDB() const { return false; } bool CCoinsView::ValidateKevaDB() const {
// TODO: return false, and implement it in txdb.cpp.
// Need to figure out what to check.
return true;
}
bool CCoinsView::HaveCoin(const COutPoint &outpoint) const bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
{ {
@ -45,7 +49,7 @@ bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock,
} }
CCoinsViewCursor *CCoinsViewBacked::Cursor() const { return base->Cursor(); } CCoinsViewCursor *CCoinsViewBacked::Cursor() const { return base->Cursor(); }
size_t CCoinsViewBacked::EstimateSize() const { return base->EstimateSize(); } size_t CCoinsViewBacked::EstimateSize() const { return base->EstimateSize(); }
bool CCoinsViewBacked::ValidateNameDB() const { return base->ValidateNameDB(); } bool CCoinsViewBacked::ValidateKevaDB() const { return base->ValidateKevaDB(); }
SaltedOutpointHasher::SaltedOutpointHasher() : k0(GetRand(std::numeric_limits<uint64_t>::max())), k1(GetRand(std::numeric_limits<uint64_t>::max())) {} SaltedOutpointHasher::SaltedOutpointHasher() : k0(GetRand(std::numeric_limits<uint64_t>::max())), k1(GetRand(std::numeric_limits<uint64_t>::max())) {}

4
src/coins.h

@ -184,7 +184,7 @@ public:
virtual CCoinsViewCursor *Cursor() const; virtual CCoinsViewCursor *Cursor() const;
// Validate the name database. // Validate the name database.
virtual bool ValidateNameDB() const; virtual bool ValidateKevaDB() const;
//! As we use CCoinsViews polymorphically, have a virtual destructor //! As we use CCoinsViews polymorphically, have a virtual destructor
virtual ~CCoinsView() {} virtual ~CCoinsView() {}
@ -214,7 +214,7 @@ public:
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) override; bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) override;
CCoinsViewCursor *Cursor() const override; CCoinsViewCursor *Cursor() const override;
size_t EstimateSize() const override; size_t EstimateSize() const override;
bool ValidateNameDB() const override; bool ValidateKevaDB() const override;
}; };

4
src/keva/main.cpp

@ -400,7 +400,7 @@ void
CheckNameDB (bool disconnect) CheckNameDB (bool disconnect)
{ {
const int option const int option
= gArgs.GetArg ("-checknamedb", Params().DefaultCheckNameDB ()); = gArgs.GetArg ("-checkkevadb", Params().DefaultCheckKevaDB ());
if (option == -1) if (option == -1)
return; return;
@ -413,7 +413,7 @@ CheckNameDB (bool disconnect)
} }
pcoinsTip->Flush (); pcoinsTip->Flush ();
const bool ok = pcoinsTip->ValidateNameDB(); const bool ok = pcoinsTip->ValidateKevaDB();
/* The DB is inconsistent (mismatch between UTXO set and names DB) between /* The DB is inconsistent (mismatch between UTXO set and names DB) between
(roughly) blocks 139,000 and 180,000. This is caused by libcoin's (roughly) blocks 139,000 and 180,000. This is caused by libcoin's

4
src/keva/main.h

@ -270,8 +270,8 @@ bool UnexpireNames (unsigned nHeight, CBlockUndo& undo,
CCoinsViewCache& view, std::set<valtype>& names); CCoinsViewCache& view, std::set<valtype>& names);
/** /**
* Check the name database consistency. This calls CCoinsView::ValidateNameDB, * Check the name database consistency. This calls CCoinsView::ValidateKevaDB,
* but only if applicable depending on the -checknamedb setting. If it fails, * but only if applicable depending on the -checkkevadb setting. If it fails,
* this throws an assertion failure. * this throws an assertion failure.
* @param disconnect Whether we are disconnecting blocks. * @param disconnect Whether we are disconnecting blocks.
*/ */

4
src/test/bloom_tests.cpp

@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
BOOST_AUTO_TEST_CASE(bloom_create_insert_key) BOOST_AUTO_TEST_CASE(bloom_create_insert_key)
{ {
std::string strSecret = std::string("6vyk9uiGUm8CCKbYue4PpoSbdWKZnjrxMQYJ1PaDGrQ4bLHTxQJ"); std::string strSecret = std::string("MdT1ZhNgpaNhvtcobunP8MHdxbBB1HLUf1FJAUkEmQqtSLtjCCo4");
CBitcoinSecret vchSecret; CBitcoinSecret vchSecret;
BOOST_CHECK(vchSecret.SetString(strSecret)); BOOST_CHECK(vchSecret.SetString(strSecret));
@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_key)
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << filter; stream << filter;
std::vector<unsigned char> vch = ParseHex("038fc16b080000000000000001"); std::vector<unsigned char> vch = ParseHex("0385f0ef080000000000000001");
std::vector<char> expected(vch.size()); std::vector<char> expected(vch.size());
for (unsigned int i = 0; i < vch.size(); i++) for (unsigned int i = 0; i < vch.size(); i++)

88
src/test/key_tests.cpp

@ -16,14 +16,10 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
static const std::string strSecret1 = "6uGFQ4DSW7zh1viHZi6iiVT17CncvoaV4MHvGvJKPDaLCdymj87"; static const std::string strSecret1C = "MdT1ZhNgpaNhvtcobunP8MHdxbBB1HLUf1FJAUkEmQqtSLtjCCo4";
static const std::string strSecret2 = "6vVo7sPkeLTwVdAntrv4Gbnsyr75H8ChD3P5iyHziwaqe8mCYR5"; static const std::string strSecret2C = "MesUJk4iXuXdau3LgYX1Se1VPzFyGkm9S4MEPRfXrYnqmaRySqDV";
static const std::string strSecret1C = "T3gJYmBuZXsdd65E7NQF88ZmUP2MaUanqnZg9GFS94W7kND4Ebjq"; static const std::string addr1C = "VRwo4qgyARQSy331bhyBPrdbp9pjgjPZiC";
static const std::string strSecret2C = "T986ZKRRdnuuXLeDZuKBRrZW1ujotAncU9WTrFU1n7vMgRW75ZtF"; static const std::string addr2C = "VMJySeGqf5o9YNkw6ma5GGWYTL5Z4Kuisw";
static const std::string addr1 = "LiUo6Zn39joYJBzPUhssbDwAywhjFcoHE3";
static const std::string addr2 = "LZJvLSP5SGKcFS13MHgdrVhpFUbEMB5XVC";
static const std::string addr1C = "Lh2G82Bi33RNuzz4UfSMZbh54jnWHVnmw8";
static const std::string addr2C = "LWegHWHB5rmaF5rgWYt1YN3StapRdnGJfU";
static const std::string strAddressBad = "Lbi6bpMhSwp2CXkivEeUK9wzyQEFzHDfSr"; static const std::string strAddressBad = "Lbi6bpMhSwp2CXkivEeUK9wzyQEFzHDfSr";
@ -32,51 +28,31 @@ 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 bsecret1C, bsecret2C, baddress1;
BOOST_CHECK( bsecret1.SetString (strSecret1));
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));
BOOST_CHECK(!baddress1.SetString(strAddressBad)); BOOST_CHECK(!baddress1.SetString(strAddressBad));
CKey key1 = bsecret1.GetKey();
BOOST_CHECK(key1.IsCompressed() == false);
CKey key2 = bsecret2.GetKey();
BOOST_CHECK(key2.IsCompressed() == false);
CKey key1C = bsecret1C.GetKey(); CKey key1C = bsecret1C.GetKey();
BOOST_CHECK(key1C.IsCompressed() == true); BOOST_CHECK(key1C.IsCompressed() == true);
CKey key2C = bsecret2C.GetKey(); CKey key2C = bsecret2C.GetKey();
BOOST_CHECK(key2C.IsCompressed() == true); BOOST_CHECK(key2C.IsCompressed() == true);
CPubKey pubkey1 = key1. GetPubKey();
CPubKey pubkey2 = key2. GetPubKey();
CPubKey pubkey1C = key1C.GetPubKey(); CPubKey pubkey1C = key1C.GetPubKey();
CPubKey pubkey2C = key2C.GetPubKey(); CPubKey pubkey2C = key2C.GetPubKey();
BOOST_CHECK(key1.VerifyPubKey(pubkey1));
BOOST_CHECK(!key1.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey1));
BOOST_CHECK(key1C.VerifyPubKey(pubkey1C)); BOOST_CHECK(key1C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C)); BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1C));
BOOST_CHECK(key2.VerifyPubKey(pubkey2));
BOOST_CHECK(!key2.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C)); BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey2));
BOOST_CHECK(key2C.VerifyPubKey(pubkey2C)); BOOST_CHECK(key2C.VerifyPubKey(pubkey2C));
BOOST_CHECK(DecodeDestination(addr1) == CTxDestination(pubkey1.GetID())); #if 0
BOOST_CHECK(DecodeDestination(addr2) == CTxDestination(pubkey2.GetID())); // Kevacoin: addr1C is Script-hash-addresses, cannot be compared
// to legacy public key hash.
BOOST_CHECK(DecodeDestination(addr1C) == CTxDestination(pubkey1C.GetID())); BOOST_CHECK(DecodeDestination(addr1C) == CTxDestination(pubkey1C.GetID()));
BOOST_CHECK(DecodeDestination(addr2C) == CTxDestination(pubkey2C.GetID())); BOOST_CHECK(DecodeDestination(addr2C) == CTxDestination(pubkey2C.GetID()));
#endif
for (int n=0; n<16; n++) for (int n=0; n<16; n++)
{ {
@ -85,76 +61,46 @@ BOOST_AUTO_TEST_CASE(key_test1)
// normal signatures // normal signatures
std::vector<unsigned char> sign1, sign2, sign1C, sign2C; std::vector<unsigned char> sign1C, sign2C;
BOOST_CHECK(key1.Sign (hashMsg, sign1));
BOOST_CHECK(key2.Sign (hashMsg, sign2));
BOOST_CHECK(key1C.Sign(hashMsg, sign1C)); BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
BOOST_CHECK(key2C.Sign(hashMsg, sign2C)); BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C)); BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C)); BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C)); BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C)); BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C));
// compact signatures (with key recovery) // compact signatures (with key recovery)
std::vector<unsigned char> csign1, csign2, csign1C, csign2C; std::vector<unsigned char> csign1C, csign2C;
BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C)); BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C)); BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
CPubKey rkey1, rkey2, rkey1C, rkey2C; CPubKey rkey1C, rkey2C;
BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1));
BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2));
BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C)); BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C));
BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C)); BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C));
BOOST_CHECK(rkey1 == pubkey1);
BOOST_CHECK(rkey2 == pubkey2);
BOOST_CHECK(rkey1C == pubkey1C); BOOST_CHECK(rkey1C == pubkey1C);
BOOST_CHECK(rkey2C == pubkey2C); BOOST_CHECK(rkey2C == pubkey2C);
} }
// test deterministic signing // test deterministic signing
std::vector<unsigned char> detsig, detsigc; std::vector<unsigned char> detsigc;
std::string strMsg = "Very deterministic message"; std::string strMsg = "Very deterministic message";
uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
BOOST_CHECK(key1.Sign(hashMsg, detsig));
BOOST_CHECK(key1C.Sign(hashMsg, detsigc)); BOOST_CHECK(key1C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc); BOOST_CHECK(detsigc == ParseHex("304402201e5a963b63e4b7f4a22ab47080fa745e313d722e92e1c38127f6675cbac4851d02205a5e67b5c1f72a496424a33e68692af9373e94ffcafbc39e4270dbd5017f078a"));
BOOST_CHECK(detsig == ParseHex("304402205dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d022014ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6"));
BOOST_CHECK(key2.Sign(hashMsg, detsig));
BOOST_CHECK(key2C.Sign(hashMsg, detsigc)); BOOST_CHECK(key2C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc); BOOST_CHECK(detsigc == ParseHex("3044022041d16f2e09478c24599a94710a12025f77431af913d9322f9baeac5d810d968f022056cc1b07e17b4f803454cbe3d842168ac4b04d676dfd18d601079b662c1df443"));
BOOST_CHECK(detsig == ParseHex("3044022052d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd5022061d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d"));
BOOST_CHECK(key1.SignCompact(hashMsg, detsig));
BOOST_CHECK(key1C.SignCompact(hashMsg, detsigc)); BOOST_CHECK(key1C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1c5dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d14ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6")); BOOST_CHECK(detsigc == ParseHex("1f1e5a963b63e4b7f4a22ab47080fa745e313d722e92e1c38127f6675cbac4851d5a5e67b5c1f72a496424a33e68692af9373e94ffcafbc39e4270dbd5017f078a"));
BOOST_CHECK(detsigc == ParseHex("205dbbddda71772d95ce91cd2d14b592cfbc1dd0aabd6a394b6c2d377bbe59d31d14ddda21494a4e221f0824f0b8b924c43fa43c0ad57dccdaa11f81a6bd4582f6"));
BOOST_CHECK(key2.SignCompact(hashMsg, detsig));
BOOST_CHECK(key2C.SignCompact(hashMsg, detsigc)); BOOST_CHECK(key2C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1c52d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd561d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d")); BOOST_CHECK(detsigc == ParseHex("2041d16f2e09478c24599a94710a12025f77431af913d9322f9baeac5d810d968f56cc1b07e17b4f803454cbe3d842168ac4b04d676dfd18d601079b662c1df443"));
BOOST_CHECK(detsigc == ParseHex("2052d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd561d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d"));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

4
src/test/main_tests.cpp

@ -51,11 +51,11 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test)
CAmount nSum = 0; CAmount nSum = 0;
for (int nHeight = 0; nHeight < 56000000 * 4; nHeight += 1000) { for (int nHeight = 0; nHeight < 56000000 * 4; nHeight += 1000) {
CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus()); CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
BOOST_CHECK(nSubsidy <= 50 * COIN); BOOST_CHECK(nSubsidy <= 500 * COIN);
nSum += nSubsidy * 1000; nSum += nSubsidy * 1000;
BOOST_CHECK(MoneyRange(nSum)); BOOST_CHECK(MoneyRange(nSum));
} }
BOOST_CHECK_EQUAL(nSum, 134398632762240000ULL); BOOST_CHECK_EQUAL(nSum, 104999999984250000ULL);
} }
bool ReturnFalse() { return false; } bool ReturnFalse() { return false; }

5
src/wallet/rpcwallet.cpp

@ -145,7 +145,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
"so payments received with the address will be credited to 'account'.\n" "so payments received with the address will be credited to 'account'.\n"
"\nArguments:\n" "\nArguments:\n"
"1. \"account\" (string, optional) DEPRECATED. The account name for the address to be linked to. If not provided, the default account \"\" is used. It can also be set to the empty string \"\" to represent the default account. The account does not need to exist, it will be created if there is no account by the given name.\n" "1. \"account\" (string, optional) DEPRECATED. The account name for the address to be linked to. If not provided, the default account \"\" is used. It can also be set to the empty string \"\" to represent the default account. The account does not need to exist, it will be created if there is no account by the given name.\n"
"2. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -addresstype.\n" "2. \"address_type\" (string, optional) The address type to use. Options are \"p2sh-segwit\" and \"bech32\". Default is set by -addresstype.\n"
"\nResult:\n" "\nResult:\n"
"\"address\" (string) The new kevacoin address\n" "\"address\" (string) The new kevacoin address\n"
"\nExamples:\n" "\nExamples:\n"
@ -166,6 +166,9 @@ UniValue getnewaddress(const JSONRPCRequest& request)
if (output_type == OUTPUT_TYPE_NONE) { if (output_type == OUTPUT_TYPE_NONE) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str())); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str()));
} }
if (output_type == OUTPUT_TYPE_LEGACY) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Legacy address type not supported"));
}
} }
if (!pwallet->IsLocked()) { if (!pwallet->IsLocked()) {

8
src/wallet/test/wallet_tests.cpp

@ -388,7 +388,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
WalletRescanReserver reserver(&wallet); WalletRescanReserver reserver(&wallet);
reserver.reserve(); reserver.reserve();
BOOST_CHECK_EQUAL(nullBlock, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver)); BOOST_CHECK_EQUAL(nullBlock, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver));
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN); BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 1000 * COIN);
} }
// Prune the older block file. // Prune the older block file.
@ -403,7 +403,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
WalletRescanReserver reserver(&wallet); WalletRescanReserver reserver(&wallet);
reserver.reserve(); reserver.reserve();
BOOST_CHECK_EQUAL(oldTip, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver)); BOOST_CHECK_EQUAL(oldTip, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver));
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN); BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 500 * COIN);
} }
// Verify importmulti RPC returns failure for a key whose creation time is // Verify importmulti RPC returns failure for a key whose creation time is
@ -531,7 +531,7 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup)
// credit amount is calculated. // credit amount is calculated.
wtx.MarkDirty(); wtx.MarkDirty();
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 50*COIN); BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 500*COIN);
} }
static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime) static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime)
@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
BOOST_CHECK_EQUAL(list.begin()->second.size(), 1); BOOST_CHECK_EQUAL(list.begin()->second.size(), 1);
// Check initial balance from one mature coinbase transaction. // Check initial balance from one mature coinbase transaction.
BOOST_CHECK_EQUAL(50 * COIN, wallet->GetAvailableBalance()); BOOST_CHECK_EQUAL(500 * COIN, wallet->GetAvailableBalance());
// Add a transaction creating a change address, and confirm ListCoins still // Add a transaction creating a change address, and confirm ListCoins still
// returns the coin associated with the change address underneath the // returns the coin associated with the change address underneath the

2
src/wallet/wallet.cpp

@ -1790,7 +1790,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter, bool fExcludeKeva) const
if(filter & ISMINE_WATCH_ONLY) if(filter & ISMINE_WATCH_ONLY)
{ {
if(fWatchDebitCached) { if(fWatchDebitCached) {
debit += (fExcludeKeva ? nWatchDebitCached : nWatchDebitWithKevaCached, false); debit += (fExcludeKeva ? nWatchDebitCached : nWatchDebitWithKevaCached);
} }
else else
{ {

Loading…
Cancel
Save