aboutsummaryrefslogtreecommitdiff
path: root/src/test/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-04-04 10:50:12 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-04-08 08:59:00 +0200
commitfa6183d7761eef8bb815aa888f0396e92e275f05 (patch)
tree0fa3bd2c44ebe7522e2f1ca68651d31881831b21 /src/test/util
parentfa732bccb3cf9bc2cdc444975286df0e799917a2 (diff)
test: Remove option to make TestChain100Setup non-deterministic
Seems odd to have an option for non-deterministic tests when the goal should be for all tests to be deterministic. Can be reviewed with `--ignore-all-space`.
Diffstat (limited to 'src/test/util')
-rw-r--r--src/test/util/setup_common.cpp32
-rw-r--r--src/test/util/setup_common.h8
2 files changed, 10 insertions, 30 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 2f3e7aee5d..2d7f335a04 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -202,26 +202,17 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
}
}
-TestChain100Setup::TestChain100Setup(bool deterministic)
+TestChain100Setup::TestChain100Setup()
{
- m_deterministic = deterministic;
-
- if (m_deterministic) {
- SetMockTime(1598887952);
- constexpr std::array<unsigned char, 32> vchKey = {
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
- }
- };
- coinbaseKey.Set(vchKey.begin(), vchKey.end(), true);
- } else {
- coinbaseKey.MakeNewKey(true);
- }
+ SetMockTime(1598887952);
+ constexpr std::array<unsigned char, 32> vchKey = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}};
+ coinbaseKey.Set(vchKey.begin(), vchKey.end(), true);
// Generate a 100-block chain:
this->mineBlocks(COINBASE_MATURITY);
- if (m_deterministic) {
+ {
LOCK(::cs_main);
assert(
m_node.chainman->ActiveChain().Tip()->GetBlockHash().ToString() ==
@@ -232,13 +223,10 @@ TestChain100Setup::TestChain100Setup(bool deterministic)
void TestChain100Setup::mineBlocks(int num_blocks)
{
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
- for (int i = 0; i < num_blocks; i++)
- {
+ for (int i = 0; i < num_blocks; i++) {
std::vector<CMutableTransaction> noTxns;
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);
- if (m_deterministic) {
- SetMockTime(GetTime() + 1);
- }
+ SetMockTime(GetTime() + 1);
m_coinbase_txns.push_back(b.vtx[0]);
}
}
@@ -315,9 +303,7 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
TestChain100Setup::~TestChain100Setup()
{
gArgs.ForceSetArg("-segwitheight", "0");
- if (m_deterministic) {
- SetMockTime(0);
- }
+ SetMockTime(0);
}
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 7323f1f0b6..a32f1f3805 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -112,7 +112,7 @@ class CScript;
* Testing fixture that pre-creates a 100-block REGTEST-mode block chain
*/
struct TestChain100Setup : public RegTestingSetup {
- TestChain100Setup(bool deterministic = false);
+ TestChain100Setup();
/**
* Create a new block with just given transactions, coinbase paying to
@@ -143,16 +143,10 @@ struct TestChain100Setup : public RegTestingSetup {
~TestChain100Setup();
- bool m_deterministic;
std::vector<CTransactionRef> m_coinbase_txns; // For convenience, coinbase transactions
CKey coinbaseKey; // private/public key needed to spend coinbase transactions
};
-
-struct TestChain100DeterministicSetup : public TestChain100Setup {
- TestChain100DeterministicSetup() : TestChain100Setup(true) { }
-};
-
/**
* Make a test setup that has disk access to the debug.log file disabled. Can
* be used in "hot loops", for example fuzzing or benchmarking.