changeset 29738:66098292c183 tip

Fix regression tests (grt still needs work)
author Troy Benjegerdes <tmagik@7el.us>
date Mon, 15 Feb 2021 16:08:27 -0600
parents 7f49a6a5c3b8
children
files src/Makefile src/Makefile.test.include src/bitcoin/Makefile.test.include src/dbwrapper.h src/grantcoin/Makefile.test.include src/litecoin/Makefile.test.include src/litecoin/litecoin.h src/make.Darwin.mk src/test/amount_tests.cpp src/test/main_tests.cpp src/test/pow_ltc_tests.cpp src/test/test_bitcoin_main.cpp src/test/transaction_tests.cpp
diffstat 12 files changed, 217 insertions(+), 168 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/Makefile	Mon Feb 15 16:08:27 2021 -0600
@@ -217,7 +217,6 @@
     $(OBJDIR)/base58.o \
     $(OBJDIR)/bech32.o \
     $(OBJDIR)/$(COIN_BRAND)/params.o \
-    $(OBJDIR)/$(COIN_BRAND)/trust.o \
     $(OBJDIR)/coins.o \
     $(OBJDIR)/compressor.o \
     $(OBJDIR)/consensus/merkle.o \
@@ -267,6 +266,7 @@
     $(OBJDIR)/policy/policy.o \
     $(OBJDIR)/policy/rbf.o \
     $(OBJDIR)/pow.o \
+    $(OBJDIR)/$(COIN_BRAND)/trust.o \
     $(OBJDIR)/rest.o \
     $(OBJDIR)/rpc/blockchain.o \
     $(OBJDIR)/rpc/misc.o \
@@ -399,14 +399,16 @@
 	mkdir -p $(DESTDIR)$(prefix)/bin
 	install -D $^ $(DESTDIR)$(prefix)/bin/
 
+test_litecoin:
+	$(MAKE) COIN_BRAND=litecoin test
 
-regression: test FORCE
-	$(MAKE) COIN_BRAND=litecoin test
+test_bitcoin:	
 	$(MAKE) COIN_BRAND=bitcoin test
+
+test_grantcoin:
 	$(MAKE) COIN_BRAND=grantcoin test
-#	$(MAKE) COIN_BRAND=grantstake test
-#	$(MAKE) COIN_BRAND=hamburger test
-#	$(MAKE) COIN_BRAND=kittycoin test
+
+regression: test_litecoin test_bitcoin test_grantcoin FORCE
 	
 
 $(TESTDIR) $(SUBDIRS):
@@ -428,8 +430,8 @@
 V_CXX=
 V_LINK=
 else
-V_CXX=@echo  "   CXX   $(CXX)    $<" ;
-V_LINK=@echo "   LINK  $(LINK)    $@" ;
+V_CXX=@echo  "  CXX\t$(COIN_BRAND)\t$(CXX)    $<" ;
+V_LINK=@echo "  LINK\t$(COIN_BRAND)\t$(LINK)    $@" ;
 endif
 
 $(OBJDIR)/build.h: FORCE
@@ -454,6 +456,14 @@
 	      -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
 	  rm -f $(@:%.o=%.d)
 
+#must be before below rule...
+$(OBJDIR)/test/%.o: test/%.cpp
+	$(V_CXX) $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
+	@cp $(@:%.o=%.d) $(@:%.o=%.P); \
+	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+	      -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
+	  rm -f $(@:%.o=%.d)
+
 $(OBJDIR)/%.o: %.cpp
 	$(V_CXX) $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
 	@cp $(@:%.o=%.d) $(@:%.o=%.P); \
@@ -475,66 +485,12 @@
 
 
 ifeq ($(ENABLE_TESTS),1)
-#maybe some other time..
-#need to set $(MKDIR_P)...
-#include Makefile.test.include
-#for now, copypasta:
-
 MKDIR_P := mkdir -p
 HEXDUMP := hexdump
 SED := sed
+include $(COIN_BRAND)/Makefile.test.include
+include Makefile.test.include
 
-JSON_TEST_FILES = \
-  test/data/script_tests.json \
-  test/data/base58_keys_valid.json \
-  test/data/base58_encode_decode.json \
-  test/data/base58_keys_invalid.json \
-  test/data/tx_invalid.json \
-  test/data/tx_valid.json \
-  test/data/sighash.json
-
-JSON_TEST_H_FILES = $(patsubst test/data/%.json,$(OBJDIR)/test/data/%.json.h,$(wildcard $(JSON_TEST_FILES)))
-
-RAW_TEST_FILES = test/data/alertTests.raw
-
-$(OBJDIR)/%.json.h: %.json
-	@mkdir -p $(@D)
-	@echo "namespace json_tests{" > $@
-	@echo "static unsigned const char $(*F)[] = {" >> $@
-	@$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x  ,//g' >> $@
-	@echo "};};" >> $@
-	@echo "Generated $@"
-
-TESTS := $(patsubst test/%.cpp,%,$(wildcard test/*_tests.cpp))
-TEST_OBJS := $(patsubst %,$(OBJDIR)/test/%.o,$(TESTS))
-TEST_EXTRA_OBJS = $(OBJDIR)/test/test_codecoin.o $(OBJDIR)/test/test_bitcoin_main.o
-
-$(TEST_OBJS): $(JSON_TEST_H_FILES) $(TESTDIR) 
-
-$(TEST_EXTRA_OBJS): $(TESTDIR)
-
-$(OBJDIR)/test/%.o: test/%.cpp
-	$(V_CXX) $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
-	@cp $(@:%.o=%.d) $(@:%.o=%.P); \
-	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-	      -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
-	  rm -f $(@:%.o=%.d)
-
-#yes this has extra cruft for scrypt. ugh.
-#filter for init.o is ugly too
-
-fltr_d_objs = $(OBJDIR)/init.o $(OBJDIR)/torcontrol.o 
-test_d_objs = $(filter-out $(fltr_d_objs),$(D_OBJS:$(OBJDIR)/%=$(OBJDIR)/%))
-
-$(TESTS): obj/test_$(COIN_BRAND) FORCE
-	./obj/test_$(COIN_BRAND) --run_test=$@
-
-test check: $(TESTS)
-
-obj/test_$(COIN_BRAND): $(test_d_objs) $(TEST_EXTRA_OBJS) \
-		$(WALLET_OBJS) $(TEST_OBJS) \
-		$(OBJDIR)/rpc/client.o $(OBJDIR)/crypto/scrypt.o $(OBJS_SSE2)
-	$(V_LINK) $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS) $(D_LIBS) $(BOOST_LIBS)
 endif
 
 clean:
--- a/src/Makefile.test.include	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/Makefile.test.include	Mon Feb 15 16:08:27 2021 -0600
@@ -1,13 +1,11 @@
 # Copyright (c) 2013-2016 The Bitcoin Core developers
-# Distributed under the MIT software license, see the accompanying
+# where * = (Lite, PP, Peerunity, Blu, Cat, Solar, URO, ...)
+# Previously distributed under the MIT/X11 software license, see the
 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-TESTS += test/test_bitcoin
-bin_PROGRAMS += test/test_bitcoin
-noinst_PROGRAMS += test/test_bitcoin_fuzzy
-TEST_SRCDIR = test
-TEST_BINARY=test/test_bitcoin$(EXEEXT)
-
+# This file is part of the Catoshi Codecoin financial cryptography software
+# Copyright (c) 2014-2018 7 Elements LLC AGPLv3
+# Distributed under the Affero GNU General public license version 3
+# file COPYING or http://www.gnu.org/licenses/agpl-3.0.html
 
 EXTRA_DIST += \
 	test/bctest.py \
@@ -71,146 +69,117 @@
   test/data/tx_valid.json \
   test/data/sighash.json
 
-RAW_TEST_FILES =
+JSON_TEST_H_FILES = $(patsubst test/data/%.json,$(OBJDIR)/test/data/%.json.h,$(wildcard $(JSON_TEST_FILES)))
+
+RAW_TEST_FILES = test/data/alertTests.raw
 
 GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
 
-# test_bitcoin binary #
-BITCOIN_TESTS =\
+# NOTE: disabled tests marked with 'Dtests'
+# test_$(COIN_BRAND) binary #
+TESTS_CPP +=\
   test/arith_uint256_tests.cpp \
   test/scriptnum10.h \
   test/addrman_tests.cpp \
   test/amount_tests.cpp \
   test/allocator_tests.cpp \
   test/base32_tests.cpp \
-  test/base58_tests.cpp \
+  test/base58_Dtests.cpp \
   test/base64_tests.cpp \
   test/bech32_tests.cpp \
-  test/bip32_tests.cpp \
-  test/blockencodings_tests.cpp \
-  test/bloom_tests.cpp \
+  test/bip32_Dtests.cpp \
+  test/blockencodings_Dtests.cpp \
+  test/bloom_Dtests.cpp \
   test/bswap_tests.cpp \
   test/checkqueue_tests.cpp \
   test/coins_tests.cpp \
   test/compress_tests.cpp \
   test/crypto_tests.cpp \
   test/cuckoocache_tests.cpp \
-  test/DoS_tests.cpp \
+  test/DoS_Dtests.cpp \
   test/getarg_tests.cpp \
   test/hash_tests.cpp \
-  test/key_tests.cpp \
+  test/key_Dtests.cpp \
   test/limitedmap_tests.cpp \
   test/dbwrapper_tests.cpp \
   test/main_tests.cpp \
   test/mempool_tests.cpp \
   test/merkle_tests.cpp \
   test/merkleblock_tests.cpp \
-  test/miner_tests.cpp \
+  test/miner_Dtests.cpp \
   test/multisig_tests.cpp \
   test/net_tests.cpp \
   test/netbase_tests.cpp \
   test/pmt_tests.cpp \
   test/policyestimator_tests.cpp \
-  test/pow_tests.cpp \
+  test/pow_Dtests.cpp \
   test/prevector_tests.cpp \
   test/raii_event_tests.cpp \
   test/random_tests.cpp \
   test/reverselock_tests.cpp \
-  test/rpc_tests.cpp \
+  test/rpc_Dtests.cpp \
   test/sanity_tests.cpp \
   test/scheduler_tests.cpp \
-  test/script_P2SH_tests.cpp \
+  test/script_P2SH_Dtests.cpp \
   test/script_P2PKH_tests.cpp \
   test/script_tests.cpp \
   test/script_standard_tests.cpp \
   test/scriptnum_tests.cpp \
   test/serialize_tests.cpp \
-  test/sighash_tests.cpp \
+  test/sighash_Dtests.cpp \
   test/sigopcount_tests.cpp \
   test/skiplist_tests.cpp \
   test/streams_tests.cpp \
-  test/test_bitcoin.cpp \
+  test/test_codecoin.cpp \
   test/test_bitcoin.h \
   test/test_bitcoin_main.cpp \
   test/timedata_tests.cpp \
   test/torcontrol_tests.cpp \
   test/transaction_tests.cpp \
-  test/txvalidation_tests.cpp \
-  test/txvalidationcache_tests.cpp \
-  test/versionbits_tests.cpp \
+  test/txvalidation_Dtests.cpp \
+  test/txvalidationcache_Dtests.cpp \
+  test/versionbits_Dtests.cpp \
   test/uint256_tests.cpp \
-  test/util_tests.cpp
+  test/util_Dtests.cpp
 
-if ENABLE_WALLET
-BITCOIN_TESTS += \
-  wallet/test/wallet_test_fixture.cpp \
-  wallet/test/wallet_test_fixture.h \
-  wallet/test/accounting_tests.cpp \
-  wallet/test/wallet_tests.cpp \
-  wallet/test/crypto_tests.cpp
-endif
+#todo enable this
+#if ENABLE_WALLET
+#TESTS_CPP += \
+#  wallet/test/wallet_test_fixture.cpp \
+#  wallet/test/wallet_test_fixture.h \
+#  wallet/test/accounting_tests.cpp \
+#  wallet/test/wallet_tests.cpp \
+#  wallet/test/crypto_tests.cpp
+#endif
 
-test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
-test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS)
-test_test_bitcoin_LDADD =
-if ENABLE_WALLET
-test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
-endif
-test_test_bitcoin_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)
-test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+TESTS := $(patsubst test/%.cpp,%,$(filter %_tests.cpp, $(TESTS_CPP)))
+TEST_OBJS := $(patsubst %,$(OBJDIR)/test/%.o,$(TESTS))
+TEST_EXTRA_OBJS = $(OBJDIR)/test/test_codecoin.o $(OBJDIR)/test/test_bitcoin_main.o
 
-test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
-test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
+$(TEST_OBJS): $(JSON_TEST_H_FILES) | $(TESTDIR)
 
-if ENABLE_ZMQ
-test_test_bitcoin_LDADD += $(ZMQ_LIBS)
-endif
-#
+$(TEST_EXTRA_OBJS): | $(TESTDIR)
 
-# test_bitcoin_fuzzy binary #
-test_test_bitcoin_fuzzy_SOURCES = test/test_bitcoin_fuzzy.cpp
-test_test_bitcoin_fuzzy_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
-test_test_bitcoin_fuzzy_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
-test_test_bitcoin_fuzzy_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+#yes this has extra cruft for scrypt. ugh.
+#filter for init.o is ugly too
 
-test_test_bitcoin_fuzzy_LDADD = \
-  $(LIBUNIVALUE) \
-  $(LIBBITCOIN_SERVER) \
-  $(LIBBITCOIN_COMMON) \
-  $(LIBBITCOIN_UTIL) \
-  $(LIBBITCOIN_CONSENSUS) \
-  $(LIBBITCOIN_CRYPTO) \
-  $(LIBSECP256K1)
+fltr_d_objs = $(OBJDIR)/init.o $(OBJDIR)/torcontrol.o 
+test_d_objs = $(filter-out $(fltr_d_objs),$(D_OBJS:$(OBJDIR)/%=$(OBJDIR)/%))
 
-test_test_bitcoin_fuzzy_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
-#
+$(TESTS): obj/test_$(COIN_BRAND) FORCE
+	./obj/test_$(COIN_BRAND) --run_test=$@
 
-nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
+test check: $(TESTS)
 
-$(BITCOIN_TESTS): $(GENERATED_TEST_FILES)
+obj/test_$(COIN_BRAND): $(test_d_objs) $(TEST_EXTRA_OBJS) \
+		$(WALLET_OBJS) $(TEST_OBJS) \
+		$(OBJDIR)/rpc/client.o $(OBJDIR)/crypto/scrypt.o $(OBJS_SSE2)
+	$(V_LINK) $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS) $(D_LIBS) $(BOOST_LIBS)
 
-CLEAN_BITCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES)
+#CLEAN_BITCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES)
+#CLEANFILES += $(CLEAN_BITCOIN_TEST)
 
-CLEANFILES += $(CLEAN_BITCOIN_TEST)
-
-bitcoin_test: $(TEST_BINARY)
-
-bitcoin_test_check: $(TEST_BINARY) FORCE
-	$(MAKE) check-TESTS TESTS=$^
-
-bitcoin_test_clean : FORCE
-	rm -f $(CLEAN_BITCOIN_TEST) $(test_test_bitcoin_OBJECTS) $(TEST_BINARY)
-
-check-local:
-	@echo "Running test/util/bitcoin-util-test.py..."
-	$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
-	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
-if EMBEDDED_UNIVALUE
-	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
-endif
-
-%.json.h: %.json
+$(OBJDIR)/%.json.h: %.json
 	@$(MKDIR_P) $(@D)
 	@{ \
 	 echo "namespace json_tests{" && \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bitcoin/Makefile.test.include	Mon Feb 15 16:08:27 2021 -0600
@@ -0,0 +1,22 @@
+
+#TODO: make this so we build all the tests for all the coins
+# but then list the ones to *exclude* from the regression run here
+ifeq ($(COIN_BRAND),bitcoin)
+
+TESTS_CPP +=\
+test/util_tests.cpp \
+test/txvalidationcache_tests.cpp \
+test/versionbits_tests.cpp \
+test/blockencodings_tests.cpp \
+test/bloom_tests.cpp \
+test/pow_tests.cpp \
+test/sighash_tests.cpp \
+
+endif
+
+ifeq ($(COIN_BRAND),litecoin)
+TESTS_CPP += \
+test/pow_ltc_tests.cpp \
+test/sighash_tests.cpp \
+
+endif
--- a/src/dbwrapper.h	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/dbwrapper.h	Mon Feb 15 16:08:27 2021 -0600
@@ -24,9 +24,11 @@
 typedef leveldb::Env DB_env;
 
 #if defined(TEST_DATA_DIR) /* hack, this is */
-#include <leveldb/helpers/memenv.h>
+//#include <leveldb/helpers/memenv.h>
 //typedef void DB_env;
-#define NEW_MEM_ENV leveldb::NewMemEnv(leveldb::Env::Default())
+//#define NEW_MEM_ENV leveldb::NewMemEnv(leveldb::Env::Default())
+#warning "fix leveldb/memenv for catoshi later"
+#define NEW_MEM_ENV nullptr
 #else
 //typedef void DB_env;
 #define NEW_MEM_ENV nullptr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/litecoin/Makefile.test.include	Mon Feb 15 16:08:27 2021 -0600
@@ -0,0 +1,1 @@
+../bitcoin/Makefile.test.include
\ No newline at end of file
--- a/src/litecoin/litecoin.h	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/litecoin/litecoin.h	Mon Feb 15 16:08:27 2021 -0600
@@ -27,7 +27,7 @@
 static const int64_t CENT = 1000000;
 
 /** Default for -minrelaytxfee, minimum relay fee for transactions */
-static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 100000;
+static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
 
 /** No amount larger than this (in satoshi) is valid */
 static const int64_t MAX_MONEY = 84000000 * COIN;
--- a/src/make.Darwin.mk	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/make.Darwin.mk	Mon Feb 15 16:08:27 2021 -0600
@@ -20,11 +20,11 @@
 	/usr/local/lib
 else
 OS_EXTRA_INCLUDE_PATH= \
-	/opt/local/include \
+	/usr/local/include \
 	/usr/local/BerkeleyDB.5.3/include
 
 OS_EXTRA_LIB_PATH= \
-	/opt/local/lib \
+	/usr/local/lib \
 	/usr/local/BerkeleyDB.5.3/lib
 endif
 
--- a/src/test/amount_tests.cpp	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/test/amount_tests.cpp	Mon Feb 15 16:08:27 2021 -0600
@@ -102,7 +102,7 @@
 {
     CFeeRate feeRate;
     feeRate = CFeeRate(1);
-    BOOST_CHECK_EQUAL(feeRate.ToString(), "0.00000001 BTC/kB");
+    BOOST_CHECK_EQUAL(feeRate.ToString(), "0.00000001 " BRAND_CODE "/kB");
 }
 
 BOOST_AUTO_TEST_SUITE_END()
--- a/src/test/main_tests.cpp	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/test/main_tests.cpp	Mon Feb 15 16:08:27 2021 -0600
@@ -49,13 +49,21 @@
 {
     const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
     CAmount nSum = 0;
-    for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
+    for (int nHeight = 0; nHeight < 56000000; nHeight += 1000) {
         CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
         BOOST_CHECK(nSubsidy <= 50 * COIN);
         nSum += nSubsidy * 1000;
         BOOST_CHECK(MoneyRange(nSum));
     }
+#if defined(BRAND_bitcoin)
     BOOST_CHECK_EQUAL(nSum, 2099999997690000ULL);
+#elif defined(BRAND_litecoin)
+    BOOST_CHECK_EQUAL(nSum, 8399999990760000ULL);
+#elif defined(BRAND_grantcoin)
+#warning "implement this"
+#else
+#error "implement subsidty_limit test"
+#endif
 }
 
 bool ReturnFalse() { return false; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/pow_ltc_tests.cpp	Mon Feb 15 16:08:27 2021 -0600
@@ -0,0 +1,98 @@
+// Copyright (c) 2015 The Bitcoin Core developers
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "chain.h"
+#include "chainparams.h"
+#include "pow.h"
+#include "random.h"
+#include "util.h"
+#include "test/test_bitcoin.h"
+
+#include <boost/test/unit_test.hpp>
+
+using namespace std;
+
+BOOST_FIXTURE_TEST_SUITE(pow_ltc_tests, BasicTestingSetup)
+
+/* Test calculation of next difficulty target with no constraints applying */
+BOOST_AUTO_TEST_CASE(get_next_work)
+{
+    SelectParams(CBaseChainParams::MAIN);
+    const Consensus::Params& params = Params().GetConsensus();
+
+    int64_t nLastRetargetTime = 1358118740; // Block #278207
+    CBlockIndex pindexLast;
+    pindexLast.nHeight = 280223;
+    pindexLast.nTime = 1358378777;  // Block #280223
+    pindexLast.nBits = 0x1c0ac141;
+    BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1c093f8d);
+}
+
+/* Test the constraint on the upper bound for next work */
+BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
+{
+    SelectParams(CBaseChainParams::MAIN);
+    const Consensus::Params& params = Params().GetConsensus();
+
+    int64_t nLastRetargetTime = 1317972665; // Block #0
+    CBlockIndex pindexLast;
+    pindexLast.nHeight = 2015;
+    pindexLast.nTime = 1318480354;  // Block #2015
+    pindexLast.nBits = 0x1e0ffff0;
+    BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1e0fffff);
+}
+
+/* Test the constraint on the lower bound for actual time taken */
+BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
+{
+    SelectParams(CBaseChainParams::MAIN);
+    const Consensus::Params& params = Params().GetConsensus();
+
+    int64_t nLastRetargetTime = 1401682934; // NOTE: Not an actual block time
+    CBlockIndex pindexLast;
+    pindexLast.nHeight = 578591;
+    pindexLast.nTime = 1401757934;  // Block #578591
+    pindexLast.nBits = 0x1b075cf1;
+    BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1b01d73c);
+}
+
+/* Test the constraint on the upper bound for actual time taken */
+BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
+{
+    SelectParams(CBaseChainParams::MAIN);
+    const Consensus::Params& params = Params().GetConsensus();
+
+    int64_t nLastRetargetTime = 1463690315; // NOTE: Not an actual block time
+    CBlockIndex pindexLast;
+    pindexLast.nHeight = 1001951;
+    pindexLast.nTime = 1464900315;  // Block #1001951
+    pindexLast.nBits = 0x1b015318;
+    BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1b054c60);
+}
+
+BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
+{
+    SelectParams(CBaseChainParams::MAIN);
+    const Consensus::Params& params = Params().GetConsensus();
+
+    std::vector<CBlockIndex> blocks(10000);
+    for (int i = 0; i < 10000; i++) {
+        blocks[i].pprev = i ? &blocks[i - 1] : NULL;
+        blocks[i].nHeight = i;
+        blocks[i].nTime = 1269211443 + i * params.nPowTargetSpacing;
+        blocks[i].nBits = 0x207fffff; /* target 0x7fffff000... */
+        blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0);
+    }
+
+    for (int j = 0; j < 1000; j++) {
+        CBlockIndex *p1 = &blocks[GetRand(10000)];
+        CBlockIndex *p2 = &blocks[GetRand(10000)];
+        CBlockIndex *p3 = &blocks[GetRand(10000)];
+
+        int64_t tdiff = GetBlockProofEquivalentTime(*p1, *p2, *p3, params);
+        BOOST_CHECK_EQUAL(tdiff, p1->GetBlockTime() - p2->GetBlockTime());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
--- a/src/test/test_bitcoin_main.cpp	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/test/test_bitcoin_main.cpp	Mon Feb 15 16:08:27 2021 -0600
@@ -2,9 +2,8 @@
 // Distributed under the MIT software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
-#define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MODULE Bitcoin Test Suite
-
+#include <codecoin.h>
+#define BOOST_TEST_MODULE Catoshi/BRAND_SYM Test Suite
 #include <net.h>
 
 #include <memory>
--- a/src/test/transaction_tests.cpp	Sun Feb 14 20:30:52 2021 -0600
+++ b/src/test/transaction_tests.cpp	Mon Feb 15 16:08:27 2021 -0600
@@ -691,14 +691,8 @@
     BOOST_CHECK(IsStandardTx(t, reason));
 
     // Check dust with default relay fee:
-    CAmount nDustThreshold = 182 * dustRelayFee.GetFeePerK()/1000;
-#if defined(BRAND_bitcoin)
+    CAmount nDustThreshold = 182 *  minRelayTxFee.GetFeePerK()/1000 * 3;
     BOOST_CHECK_EQUAL(nDustThreshold, 546);
-#elif defined(BRAND_litecoin)
-    BOOST_CHECK_EQUAL(nDustThreshold, 54600);
-#else
-    #warning "Add correct BOOST_CHECK_EQUAL for coin" // TODO	
-#endif
     // dust:
     t.vout[0].nValue = nDustThreshold - 1;
     BOOST_CHECK(!IsStandardTx(t, reason));