Rebase LBRY on top of Bitcoin 0.17 #263

Closed
lbrynaut wants to merge 18 commits from updated-rebase-0.17-deps into bitcoin-0.17
16 changed files with 746 additions and 650 deletions
Showing only changes of commit 9638c936f8 - Show all commits

View file

@ -2,10 +2,10 @@
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
bin_PROGRAMS += test/test_bitcoin bin_PROGRAMS += test/test_lbrycrd
noinst_PROGRAMS += test/test_bitcoin_fuzzy noinst_PROGRAMS += test/test_lbrycrd_fuzzy
TEST_SRCDIR = test TEST_SRCDIR = test
TEST_BINARY=test/test_bitcoin$(EXEEXT) TEST_BINARY=test/test_lbrycrd$(EXEEXT)
JSON_TEST_FILES = \ JSON_TEST_FILES = \
test/data/base58_encode_decode.json \ test/data/base58_encode_decode.json \
@ -111,32 +111,32 @@ BITCOIN_TEST_SUITE += \
wallet/test/wallet_test_fixture.h wallet/test/wallet_test_fixture.h
endif endif
test_test_bitcoin_SOURCES = $(BITCOIN_TEST_SUITE) $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES) test_test_lbrycrd_SOURCES = $(BITCOIN_TEST_SUITE) $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS) test_test_lbrycrd_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS)
test_test_bitcoin_LDADD = test_test_lbrycrd_LDADD =
if ENABLE_WALLET if ENABLE_WALLET
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET) test_test_lbrycrd_LDADD += $(LIBBITCOIN_WALLET)
endif endif
test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ test_test_lbrycrd_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) test_test_lbrycrd_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) test_test_lbrycrd_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static test_test_lbrycrd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
if ENABLE_ZMQ if ENABLE_ZMQ
test_test_bitcoin_LDADD += $(ZMQ_LIBS) test_test_lbrycrd_LDADD += $(ZMQ_LIBS)
endif endif
# #
# test_bitcoin_fuzzy binary # # test_bitcoin_fuzzy binary #
test_test_bitcoin_fuzzy_SOURCES = test/test_bitcoin_fuzzy.cpp test_test_lbrycrd_fuzzy_SOURCES = test/test_bitcoin_fuzzy.cpp
test_test_bitcoin_fuzzy_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) test_test_lbrycrd_fuzzy_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
test_test_bitcoin_fuzzy_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) test_test_lbrycrd_fuzzy_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_test_bitcoin_fuzzy_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) test_test_lbrycrd_fuzzy_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_test_bitcoin_fuzzy_LDADD = \ test_test_lbrycrd_fuzzy_LDADD = \
$(LIBUNIVALUE) \ $(LIBUNIVALUE) \
$(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_COMMON) \
@ -148,10 +148,10 @@ test_test_bitcoin_fuzzy_LDADD = \
$(LIBBITCOIN_CRYPTO_SHANI) \ $(LIBBITCOIN_CRYPTO_SHANI) \
$(LIBSECP256K1) $(LIBSECP256K1)
test_test_bitcoin_fuzzy_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) test_test_lbrycrd_fuzzy_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# #
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) nodist_test_test_lbrycrd_SOURCES = $(GENERATED_TEST_FILES)
$(BITCOIN_TESTS): $(GENERATED_TEST_FILES) $(BITCOIN_TESTS): $(GENERATED_TEST_FILES)
@ -159,13 +159,13 @@ CLEAN_BITCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES)
CLEANFILES += $(CLEAN_BITCOIN_TEST) CLEANFILES += $(CLEAN_BITCOIN_TEST)
bitcoin_test: $(TEST_BINARY) lbrycrd_test: $(TEST_BINARY)
bitcoin_test_check: $(TEST_BINARY) FORCE lbrycrd_test_check: $(TEST_BINARY) FORCE
$(MAKE) check-TESTS TESTS=$^ $(MAKE) check-TESTS TESTS=$^
bitcoin_test_clean : FORCE lbrycrd_test_clean : FORCE
rm -f $(CLEAN_BITCOIN_TEST) $(test_test_bitcoin_OBJECTS) $(TEST_BINARY) rm -f $(CLEAN_BITCOIN_TEST) $(test_test_lbrycrd_OBJECTS) $(TEST_BINARY)
check-local: $(BITCOIN_TESTS:.cpp=.cpp.test) check-local: $(BITCOIN_TESTS:.cpp=.cpp.test)
@echo "Running test/util/bitcoin-util-test.py..." @echo "Running test/util/bitcoin-util-test.py..."

View file

@ -194,16 +194,15 @@ public:
vSeeds.emplace_back("dnsseed2.lbry.io"); // lbry.io vSeeds.emplace_back("dnsseed2.lbry.io"); // lbry.io
vSeeds.emplace_back("dnsseed3.lbry.io"); // lbry.io vSeeds.emplace_back("dnsseed3.lbry.io"); // lbry.io
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0x55); base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,0x7a); base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,0x1c); base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
base58Prefixes[EXT_PUBLIC_KEY] = {0x01, 0x9c, 0x35, 0x4F}; base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
base58Prefixes[EXT_SECRET_KEY] = {0x01, 0x9c, 0x31, 0x18}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
/* bech32_hrp = "bc"; */ bech32_hrp = "bc";
bech32_hrp = "lb"; // FIXME: change this?
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
@ -309,8 +308,7 @@ public:
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
/* bech32_hrp = "tb"; */ bech32_hrp = "tb";
bech32_hrp = "lt"; // FIXME: change?
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));

View file

@ -38,45 +38,53 @@ struct TestVector {
TestVector test1 = TestVector test1 =
TestVector("000102030405060708090a0b0c0d0e0f") TestVector("000102030405060708090a0b0c0d0e0f")
("Lpub2hkYkGHXktBhLCamCogeqGV7fQatCHyAe3LstjaUdvp6syZNaSGjdxf68TZG1hmc4Dz1dnMnZad1HHiS3DopTy4QxrMcSbiGir5nXrU2xFd", ("xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"LprvXPsFZUGgrX1X8fNGTeYQawgXAMnj4SeUu4SpYk4vfQ5MtF16HTUVzFEmFmfM4D4JQ66TyH2y3X1SAkMtYvV455cRn2EPLb1DyK21SWCtZac", "xprv9s21ZrQH143K3QTDL4LXw2F7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vXEYBVPamhGW6cFJodrTHy",
"LprvXasE7cg6LxvAahbgT4V6cvsjem4kABa16G45rgRdGcPPy92GpSDMS5fKKJc2QfFJjtJC997hgrcuj1ZQeN2V5krdT2H8UEJLPhjyHjdGM3u", "xprvA41z7zogVVwxVSgdKUHDy1SKmdb533PjDz7J6N6mV6uS3ze1ai8FHa8kmHScGpWmj4WggLyQjgPie1rFSruoUihUZREPSL39UNdE3BBDu76",
0); 0);
TestVector test2 = TestVector test2 =
TestVector("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484\ TestVector("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542")
542") ("xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB",
("Lpub2hkYkGHXktBhKp66JxkwHUCsubjJsvDzKd8cBgKJcJvyAxaZkb3g4rpgUZeEix8ZxnDoYT1wxf8G15SfAQiybt4MpnZ5H6Cw3DktojFA2uq", "xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U",
"LprvXPsFZUGgrX1X8GsbZoch39QHQYw9k4uJaeEYqgokdnCEBE2HTcFSR9QMbqSQEicPe8qtiZVRKd3dGH5zbLskgSwCESJdUvuxYZeEoQkoij6",
0) 0)
("Lpub2m2J1yyVEu1mr5gPSk8pMGcQGZUZatiGsnsyMVLkginvrw2YKrPkDhPw42c8X391B6hyQg1hMjyEAEsM3ZRPwUie6qHkBSMKAhsZEyWPpRJ", ("xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMw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W4BYPJcr9E7j",
0);
TestVector test3 =
TestVector("4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be")
("xpub661MyMwAqRbcEZVB4dScxMAdx6d4nFc9nvyvH3v4gJL378CSRZiYmhRoP7mBy6gSPSCYk6SzXPTf3ND1cZAceL7SfJ1Z3GC8vBgp2epUt13",
"xprv9s21ZrQH143K25QhxbucbDDuQ4naNntJRi4KUfWT7xo4EKsHt2QJDu7KXp1A3u7Bi1j8ph3EGsZ9Xvz9dGuVrtHHs7pXeTzjuxBrCmmhgC6",
0x80000000)
("xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y",
"xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L",
0); 0);
static void RunTest(const TestVector &test) { static void RunTest(const TestVector &test) {
@ -139,4 +147,8 @@ BOOST_AUTO_TEST_CASE(bip32_test2) {
RunTest(test2); RunTest(test2);
} }
BOOST_AUTO_TEST_CASE(bip32_test3) {
RunTest(test3);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,6 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
using namespace std; using namespace std;
class CClaimTrieCacheTest : public CClaimTrieCache { class CClaimTrieCacheTest : public CClaimTrieCache {
public: public:
CClaimTrieCacheTest(CClaimTrie* base): CClaimTrieCacheTest(CClaimTrie* base):
@ -66,12 +65,12 @@ BOOST_AUTO_TEST_CASE(merkle_hash_single_test)
// check empty trie // check empty trie
uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001")); uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
CClaimTrieCacheTest cc(pclaimTrie); CClaimTrieCacheTest cc(pclaimTrie);
BOOST_CHECK(one == cc.getMerkleHash()); BOOST_CHECK_EQUAL(one, cc.getMerkleHash());
// check trie with only root node // check trie with only root node
CClaimTrieNode base_node; CClaimTrieNode base_node;
cc.recursiveComputeMerkleHash(&base_node, ""); cc.recursiveComputeMerkleHash(&base_node, "");
BOOST_CHECK(one == cc.getMerkleHash()); BOOST_CHECK_EQUAL(one, cc.getMerkleHash());
} }
BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test) BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
@ -112,19 +111,19 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
BOOST_CHECK(pclaimTrie->empty()); BOOST_CHECK(pclaimTrie->empty());
BOOST_CHECK(!ntState.empty()); BOOST_CHECK(!ntState.empty());
BOOST_CHECK(ntState.getMerkleHash() == hash1); BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash1);
ntState.insertClaimIntoTrie(std::string("test"), CClaimValue(tx3OutPoint, hash160, 50, 101, 201)); ntState.insertClaimIntoTrie(std::string("test"), CClaimValue(tx3OutPoint, hash160, 50, 101, 201));
BOOST_CHECK(ntState.getMerkleHash() == hash1); BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash1);
ntState.insertClaimIntoTrie(std::string("tes"), CClaimValue(tx4OutPoint, hash160, 50, 100, 200)); ntState.insertClaimIntoTrie(std::string("tes"), CClaimValue(tx4OutPoint, hash160, 50, 100, 200));
BOOST_CHECK(ntState.getMerkleHash() == hash2); BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash2);
ntState.insertClaimIntoTrie(std::string("testtesttesttest"), CClaimValue(tx5OutPoint, hash160, 50, 100, 200)); ntState.insertClaimIntoTrie(std::string("testtesttesttest"), CClaimValue(tx5OutPoint, hash160, 50, 100, 200));
ntState.removeClaimFromTrie(std::string("testtesttesttest"), tx5OutPoint, unused); ntState.removeClaimFromTrie(std::string("testtesttesttest"), tx5OutPoint, unused);
BOOST_CHECK(ntState.getMerkleHash() == hash2); BOOST_CHECK_EQUAL(ntState.getMerkleHash(), hash2);
ntState.flush(); ntState.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash2); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash2);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState1(pclaimTrie, false); CClaimTrieCache ntState1(pclaimTrie, false);
@ -133,52 +132,52 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
ntState1.removeClaimFromTrie(std::string("test"), tx3OutPoint, unused); ntState1.removeClaimFromTrie(std::string("test"), tx3OutPoint, unused);
ntState1.removeClaimFromTrie(std::string("tes"), tx4OutPoint, unused); ntState1.removeClaimFromTrie(std::string("tes"), tx4OutPoint, unused);
BOOST_CHECK(ntState1.getMerkleHash() == hash0); BOOST_CHECK_EQUAL(ntState1.getMerkleHash(), hash0);
CClaimTrieCache ntState2(pclaimTrie, false); CClaimTrieCache ntState2(pclaimTrie, false);
ntState2.insertClaimIntoTrie(std::string("abab"), CClaimValue(tx6OutPoint, hash160, 50, 100, 200)); ntState2.insertClaimIntoTrie(std::string("abab"), CClaimValue(tx6OutPoint, hash160, 50, 100, 200));
ntState2.removeClaimFromTrie(std::string("test"), tx1OutPoint, unused); ntState2.removeClaimFromTrie(std::string("test"), tx1OutPoint, unused);
BOOST_CHECK(ntState2.getMerkleHash() == hash3); BOOST_CHECK_EQUAL(ntState2.getMerkleHash(), hash3);
ntState2.flush(); ntState2.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash3); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash3);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState3(pclaimTrie, false); CClaimTrieCache ntState3(pclaimTrie, false);
ntState3.insertClaimIntoTrie(std::string("test"), CClaimValue(tx1OutPoint, hash160, 50, 100, 200)); ntState3.insertClaimIntoTrie(std::string("test"), CClaimValue(tx1OutPoint, hash160, 50, 100, 200));
BOOST_CHECK(ntState3.getMerkleHash() == hash4); BOOST_CHECK_EQUAL(ntState3.getMerkleHash(), hash4);
ntState3.flush(); ntState3.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash4); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash4);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState4(pclaimTrie, false); CClaimTrieCache ntState4(pclaimTrie, false);
ntState4.removeClaimFromTrie(std::string("abab"), tx6OutPoint, unused); ntState4.removeClaimFromTrie(std::string("abab"), tx6OutPoint, unused);
BOOST_CHECK(ntState4.getMerkleHash() == hash2); BOOST_CHECK_EQUAL(ntState4.getMerkleHash(), hash2);
ntState4.flush(); ntState4.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash2); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash2);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState5(pclaimTrie, false); CClaimTrieCache ntState5(pclaimTrie, false);
ntState5.removeClaimFromTrie(std::string("test"), tx3OutPoint, unused); ntState5.removeClaimFromTrie(std::string("test"), tx3OutPoint, unused);
BOOST_CHECK(ntState5.getMerkleHash() == hash2); BOOST_CHECK_EQUAL(ntState5.getMerkleHash(), hash2);
ntState5.flush(); ntState5.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash2); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash2);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState6(pclaimTrie, false); CClaimTrieCache ntState6(pclaimTrie, false);
ntState6.insertClaimIntoTrie(std::string("test"), CClaimValue(tx3OutPoint, hash160, 50, 101, 201)); ntState6.insertClaimIntoTrie(std::string("test"), CClaimValue(tx3OutPoint, hash160, 50, 101, 201));
BOOST_CHECK(ntState6.getMerkleHash() == hash2); BOOST_CHECK_EQUAL(ntState6.getMerkleHash(), hash2);
ntState6.flush(); ntState6.flush();
BOOST_CHECK(!pclaimTrie->empty()); BOOST_CHECK(!pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash2); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash2);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
CClaimTrieCache ntState7(pclaimTrie, false); CClaimTrieCache ntState7(pclaimTrie, false);
@ -187,10 +186,10 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
ntState7.removeClaimFromTrie(std::string("tes"), tx4OutPoint, unused); ntState7.removeClaimFromTrie(std::string("tes"), tx4OutPoint, unused);
ntState7.removeClaimFromTrie(std::string("test2"), tx2OutPoint, unused); ntState7.removeClaimFromTrie(std::string("test2"), tx2OutPoint, unused);
BOOST_CHECK(ntState7.getMerkleHash() == hash0); BOOST_CHECK_EQUAL(ntState7.getMerkleHash(), hash0);
ntState7.flush(); ntState7.flush();
BOOST_CHECK(pclaimTrie->empty()); BOOST_CHECK(pclaimTrie->empty());
BOOST_CHECK(pclaimTrie->getMerkleHash() == hash0); BOOST_CHECK_EQUAL(pclaimTrie->getMerkleHash(), hash0);
BOOST_CHECK(pclaimTrie->checkConsistency()); BOOST_CHECK(pclaimTrie->checkConsistency());
} }
@ -214,14 +213,14 @@ BOOST_AUTO_TEST_CASE(basic_insertion_info_test)
// try getClaimsForName, getEffectiveAmountForClaim, getInfoForName // try getClaimsForName, getEffectiveAmountForClaim, getInfoForName
claimsForNameType res = ctc.getClaimsForName("test"); claimsForNameType res = ctc.getClaimsForName("test");
BOOST_CHECK(res.claims.size() == 1); BOOST_CHECK_EQUAL(res.claims.size(), 1);
BOOST_CHECK(res.claims[0] == claimVal); BOOST_CHECK_EQUAL(res.claims[0], claimVal);
BOOST_CHECK_EQUAL(10, ctc.getEffectiveAmountForClaim("test", claimId)); BOOST_CHECK_EQUAL(10, ctc.getEffectiveAmountForClaim("test", claimId));
CClaimValue claim; CClaimValue claim;
BOOST_CHECK(ctc.getInfoForName("test", claim)); BOOST_CHECK(ctc.getInfoForName("test", claim));
BOOST_CHECK(claim == claimVal); BOOST_CHECK_EQUAL(claim, claimVal);
// insert a support // insert a support
CAmount supportAmount(10); CAmount supportAmount(10);
@ -298,7 +297,7 @@ BOOST_AUTO_TEST_CASE(iteratetrie_test)
{ {
count++; count++;
if (name == "test") { if (name == "test") {
BOOST_CHECK(node->claims.size() == 1); BOOST_CHECK_EQUAL(node->claims.size(), 1);
} }
} }
@ -306,7 +305,7 @@ BOOST_AUTO_TEST_CASE(iteratetrie_test)
} testCallback(count); } testCallback(count);
BOOST_CHECK(ctc.iterateTrie(testCallback)); BOOST_CHECK(ctc.iterateTrie(testCallback));
BOOST_CHECK(count == 5); BOOST_CHECK_EQUAL(count, 5);
count = 3; count = 3;
@ -325,7 +324,7 @@ BOOST_AUTO_TEST_CASE(iteratetrie_test)
} testCallback2(count); } testCallback2(count);
BOOST_CHECK(!ctc.iterateTrie(testCallback2)); BOOST_CHECK(!ctc.iterateTrie(testCallback2));
BOOST_CHECK(count == 0); BOOST_CHECK_EQUAL(count, 0);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View file

@ -16,7 +16,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
int ApplyTxInUndo(unsigned int index, const CTxUndo& txUndo, CCoinsViewCache& view, CClaimTrieCache& trieCache, const COutPoint& out); int ApplyTxInUndo(unsigned int index, CTxUndo& txUndo, CCoinsViewCache& view, CClaimTrieCache& trieCache, const COutPoint& out);
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txundo, int nHeight); void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txundo, int nHeight);
namespace namespace
@ -95,7 +95,7 @@ public:
} // namespace } // namespace
BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup) BOOST_FIXTURE_TEST_SUITE(coins_tests, TestingSetup)
static const unsigned int NUM_SIMULATION_ITERATIONS = 40000; static const unsigned int NUM_SIMULATION_ITERATIONS = 40000;
@ -409,6 +409,8 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
Coin coin = undo.vprevout[0]; Coin coin = undo.vprevout[0];
CClaimTrieCache trieCache(pclaimTrie); CClaimTrieCache trieCache(pclaimTrie);
ApplyTxInUndo(0, undo, *(stack.back()), trieCache, out); ApplyTxInUndo(0, undo, *(stack.back()), trieCache, out);
// return coin
undo.vprevout[0] = coin;
} }
// Store as a candidate for reconnection // Store as a candidate for reconnection
disconnected_coins.insert(utxod->first); disconnected_coins.insert(utxod->first);

View file

@ -17,15 +17,15 @@ BOOST_FIXTURE_TEST_SUITE(merkleblock_tests, BasicTestingSetup)
*/ */
BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_found) BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_found)
{ {
CBlock block = getBlock13b8a(); CBlock block = getTestBlock();
std::set<uint256> txids; std::set<uint256> txids;
// Last txn in block. // Last txn in block.
uint256 txhash1 = uint256S("0x74d681e0e03bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20"); uint256 txhash1 = uint256S("0x9ce94190112f5b6763fb73a813c7bc2b63f1279f4345d2815abe3d7b2b0052cf");
// Second txn in block. // Second txn in block.
uint256 txhash2 = uint256S("0xf9fc751cb7dc372406a9f8d738d5e6f8f63bab71986a39cf36ee70ee17036d07"); uint256 txhash2 = uint256S("0x284a6aee6143497ebfede92f4877945714c0a041d79e49e7664fc6299e55d61e");
txids.insert(txhash1); txids.insert(txhash1);
txids.insert(txhash2); txids.insert(txhash2);
@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_found)
BOOST_CHECK_EQUAL(vIndex[0], 1U); BOOST_CHECK_EQUAL(vIndex[0], 1U);
BOOST_CHECK_EQUAL(vMatched[1].ToString(), txhash1.ToString()); BOOST_CHECK_EQUAL(vMatched[1].ToString(), txhash1.ToString());
BOOST_CHECK_EQUAL(vIndex[1], 8U); BOOST_CHECK_EQUAL(vIndex[1], 3U);
} }
@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_found)
*/ */
BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_not_found) BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_not_found)
{ {
CBlock block = getBlock13b8a(); CBlock block = getTestBlock();
std::set<uint256> txids2; std::set<uint256> txids2;
txids2.insert(uint256S("0xc0ffee00003bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20")); txids2.insert(uint256S("0xc0ffee00003bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20"));

View file

@ -11,6 +11,7 @@
#include <validation.h> #include <validation.h>
#include <miner.h> #include <miner.h>
#include <policy/policy.h> #include <policy/policy.h>
#include <pow.h>
#include <pubkey.h> #include <pubkey.h>
#include <script/standard.h> #include <script/standard.h>
#include <txmempool.h> #include <txmempool.h>
@ -47,7 +48,7 @@ static BlockAssembler AssemblerForTest(const CChainParams& params) {
return BlockAssembler(params, options); return BlockAssembler(params, options);
} }
static /*static
struct { struct {
unsigned char extranonce; unsigned char extranonce;
unsigned int nonce; unsigned int nonce;
@ -82,6 +83,20 @@ struct {
{2, 0xbbbeb305}, {2, 0xfe1c810a}, {2, 0xbbbeb305}, {2, 0xfe1c810a},
}; };
const unsigned int nonces[] = {
9875, 95807, 31359, 234335, 145717, 80791, 112145, 24413, 180722, 9910,
43622, 8531, 6247, 21164, 31399, 115014, 6240, 11855, 15380, 16059,
151773, 42247, 258112, 33467, 66678, 118631, 31485, 53636, 74882, 4123,
86392, 11386, 58121, 27870, 76602, 17616, 80966, 37064, 84547, 58182,
169550, 11965, 63424, 245620, 4710, 6134, 77310, 100050, 134882, 44029,
3970, 175316, 56994, 23523, 12055, 15866, 25422, 71227, 105999, 107878,
75188, 17820, 54863, 74022, 81834, 121376, 67397, 10857, 22081, 33061,
65027, 46272, 56681, 1209, 151028, 82788, 7817, 92273, 55392, 15714,
94174, 21541, 33833, 30596, 93204, 53265, 51495, 59980, 91955, 57202,
40559, 23761, 75982, 4582, 3207, 109694, 12944, 93689, 47593, 20997,
194095, 112324, 146676, 66180, 33360, 140817, 731, 19918, 31681, 19541,
};*/
static CBlockIndex CreateBlockIndex(int nHeight) static CBlockIndex CreateBlockIndex(int nHeight)
{ {
CBlockIndex index; CBlockIndex index;
@ -216,6 +231,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
entry.nFee = 11; entry.nFee = 11;
entry.nHeight = 11; entry.nHeight = 11;
LOCK(cs_main);
fCheckpointsEnabled = false; fCheckpointsEnabled = false;
// Simple block creation, nothing special yet: // Simple block creation, nothing special yet:
@ -225,34 +241,37 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
// Therefore, load 100 blocks :) // Therefore, load 100 blocks :)
int baseheight = 0; int baseheight = 0;
std::vector<CTransactionRef> txFirst; std::vector<CTransactionRef> txFirst;
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i) for (unsigned int i = 0; i < 110; ++i)
{ {
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
CBlock *pblock = &pblocktemplate->block; // pointer for convenience CBlock *pblock = &pblocktemplate->block; // pointer for convenience
{ pblock->hashPrevBlock = chainActive.Tip()->GetBlockHash();
LOCK(cs_main); pblock->nVersion = 5;
pblock->nVersion = 1; pblock->nTime = chainActive.Tip()->GetBlockTime() + chainparams.GetConsensus().nPowTargetSpacing;
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1;
CMutableTransaction txCoinbase(*pblock->vtx[0]); CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.nVersion = 1; txCoinbase.vin[0].scriptSig = CScript() << int(chainActive.Height() + 1) << i;
txCoinbase.vin[0].scriptSig = CScript();
txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce);
txCoinbase.vin[0].scriptSig.push_back(chainActive.Height());
txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this) txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
txCoinbase.vout[0].scriptPubKey = CScript(); txCoinbase.vout[0].nValue = GetBlockSubsidy(chainActive.Height() + 1, chainparams.GetConsensus());
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
if (txFirst.size() == 0) if (txFirst.size() == 0)
baseheight = chainActive.Height(); baseheight = chainActive.Height();
if (txFirst.size() < 4) if (txFirst.size() < 4)
txFirst.push_back(pblock->vtx[0]); txFirst.push_back(pblock->vtx[0]);
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
pblock->nNonce = blockinfo[i].nonce;
for (uint32_t i = 0;; ++i) {
pblock->nNonce = i;
if (CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, chainparams.GetConsensus())) {
break;
}
}
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
if (!ProcessNewBlock(chainparams, shared_pblock, true, nullptr)) {
std::cout << pblock->ToString() << '\n';
} }
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
BOOST_CHECK(ProcessNewBlock(chainparams, shared_pblock, true, nullptr));
pblock->hashPrevBlock = pblock->GetHash();
} }
LOCK(cs_main);
LOCK(::mempool.cs); LOCK(::mempool.cs);
// Just to make sure we can still make simple blocks // Just to make sure we can still make simple blocks

View file

@ -3,7 +3,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test/test_bitcoin.h" #include "test/test_bitcoin.h"
//BOOST_FIXTURE_TEST_SUITE(nameclaim_tests, BasicTestingSetup) BOOST_FIXTURE_TEST_SUITE(nameclaim_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(calc_min_claimtrie_fee) BOOST_AUTO_TEST_CASE(calc_min_claimtrie_fee)
{ {
@ -33,6 +33,4 @@ BOOST_AUTO_TEST_CASE(calc_min_claimtrie_fee)
} }
BOOST_AUTO_TEST_SUITE_END()
//BOOST_AUTO_TEST_SUITE_END()

View file

@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
pindexLast.nHeight = 32255; pindexLast.nHeight = 32255;
pindexLast.nTime = 1262152739; // Block #32255 pindexLast.nTime = 1262152739; // Block #32255
pindexLast.nBits = 0x1d00ffff; pindexLast.nBits = 0x1d00ffff;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00d86aU); BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1D03FFFCU);
} }
/* Test the constraint on the upper bound for next work */ /* Test the constraint on the upper bound for next work */
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
pindexLast.nHeight = 2015; pindexLast.nHeight = 2015;
pindexLast.nTime = 1233061996; // Block #2015 pindexLast.nTime = 1233061996; // Block #2015
pindexLast.nBits = 0x1d00ffff; pindexLast.nBits = 0x1d00ffff;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00ffffU); BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1D03FFFCU);
} }
/* Test the constraint on the lower bound for actual time taken */ /* Test the constraint on the lower bound for actual time taken */
@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
pindexLast.nHeight = 68543; pindexLast.nHeight = 68543;
pindexLast.nTime = 1279297671; // Block #68543 pindexLast.nTime = 1279297671; // Block #68543
pindexLast.nBits = 0x1c05a3f4; pindexLast.nBits = 0x1c05a3f4;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1c0168fdU); BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1C168FD0U);
} }
/* Test the constraint on the upper bound for actual time taken */ /* Test the constraint on the upper bound for actual time taken */

View file

@ -338,20 +338,19 @@ BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress)
BOOST_AUTO_TEST_CASE(rpc_claimtrie_validation) BOOST_AUTO_TEST_CASE(rpc_claimtrie_validation)
{ {
// std::runtime_error: parameter 2 must be hexadecimal string (not 'not_hex') // std::runtime_error: parameter 2 must be hexadecimal string (not 'not_hex')
BOOST_CHECK_THROW(RPCConvertValues("getnameproof", {"test", "not_hex"}), std::runtime_error); BOOST_CHECK_THROW(CallRPC("getnameproof test not_hex"), std::runtime_error);
// std::runtime_error: Block not found // std::runtime_error: Block not found
BOOST_CHECK_THROW(RPCConvertValues("getnameproof", {"test", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}), std::runtime_error); BOOST_CHECK_THROW(CallRPC("getnameproof test aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), std::runtime_error);
// Generate a block to validate the NO_THROW case. // Generate a block to validate the NO_THROW case.
UniValue result = CallRPC("generate 1"); BOOST_CHECK_NO_THROW(CallRPC("getnameproof test"));
BOOST_CHECK_NO_THROW(result = RPCConvertValues("getnameproof", {"test", result[0].get_str()}));
/* BOOST_CHECK_THROW(CallRPC("getclaimsfortx not_hex"), runtime_error); */ BOOST_CHECK_THROW(CallRPC("getclaimsfortx not_hex"), std::runtime_error);
/* BOOST_CHECK_NO_THROW(CallRPC("getclaimsfortx aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); */ BOOST_CHECK_NO_THROW(CallRPC("getclaimsfortx aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
/* BOOST_CHECK_THROW(CallRPC("getclaimbyid not_hex"), runtime_error); */ BOOST_CHECK_THROW(CallRPC("getclaimbyid not_hex"), std::runtime_error);
/* // Wrong length. */ // Wrong length. */
/* BOOST_CHECK_THROW(CallRPC("getclaimbyid a"), runtime_error); */ BOOST_CHECK_THROW(CallRPC("getclaimbyid a"), std::runtime_error);
/* BOOST_CHECK_NO_THROW(CallRPC("getclaimbyid aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); */ BOOST_CHECK_NO_THROW(CallRPC("getclaimbyid aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
} }
BOOST_AUTO_TEST_CASE(rpc_getblockstats_calculate_percentiles_by_weight) BOOST_AUTO_TEST_CASE(rpc_getblockstats_calculate_percentiles_by_weight)

File diff suppressed because one or more lines are too long

View file

@ -127,9 +127,17 @@ struct TestMemPoolEntryHelper
TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; } TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
}; };
CBlock getBlock13b8a(); CBlock getTestBlock();
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_* // define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
std::ostream& operator<<(std::ostream& os, const uint256& num); std::ostream& operator<<(std::ostream& os, const uint256& num);
std::ostream& operator<<(std::ostream& os, const uint160& num);
std::ostream& operator<<(std::ostream& os, const COutPoint& point);
class CClaimValue;
std::ostream& operator<<(std::ostream& os, const CClaimValue& claim);
class CClaimTrieNode;
std::ostream& operator<<(std::ostream& os, const CClaimTrieNode& node);
#endif #endif

View file

@ -1442,9 +1442,9 @@ static bool AbortNode(CValidationState& state, const std::string& strMessage, co
* @param out The out point that corresponds to the tx input. * @param out The out point that corresponds to the tx input.
* @return A DisconnectResult as an int * @return A DisconnectResult as an int
*/ */
int ApplyTxInUndo(unsigned int index, const CTxUndo& txUndo, CCoinsViewCache& view, CClaimTrieCache& trieCache, const COutPoint& out) int ApplyTxInUndo(unsigned int index, CTxUndo& txUndo, CCoinsViewCache& view, CClaimTrieCache& trieCache, const COutPoint& out)
{ {
Coin& undo = const_cast<Coin&>(txUndo.vprevout[index]); Coin& undo = txUndo.vprevout[index];
unsigned int nClaimValidHeight = 0; unsigned int nClaimValidHeight = 0;
bool fIsClaim = false; bool fIsClaim = false;
const auto claimIt = txUndo.claimInfo.find(index); const auto claimIt = txUndo.claimInfo.find(index);

View file

@ -363,9 +363,8 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp = null
/** /**
* Global state * Global state
*/ */
namespace { struct CBlockIndexWorkComparator
struct CBlockIndexWorkComparator {
{
bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const { bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
// First sort by most total work, ... // First sort by most total work, ...
if (pa->nChainWork > pb->nChainWork) return false; if (pa->nChainWork > pb->nChainWork) return false;
@ -383,8 +382,7 @@ namespace {
// Identical blocks. // Identical blocks.
return false; return false;
} }
}; };
} // anon namespace
class ConnectTrace; class ConnectTrace;