fork_util.h raw

   1  // Copyright (c) 2025 The Limenka developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  
   5  #ifndef LIMENKA_TEST_FORK_UTIL_H
   6  #define LIMENKA_TEST_FORK_UTIL_H
   7  
   8  #include <chainparams.h>
   9  #include <consensus/params.h>
  10  #include <kernel/chainparams.h>
  11  #include <test/util/setup_common.h>
  12  #include <util/vector.h>
  13  
  14  #include <cstdint>
  15  
  16  /** Lightweight fixture for fork chain parameter tests.
  17   *  Uses ChainType::FORK directly via TestingSetup (not TestChain100Setup,
  18   *  which hardcodes REGTEST).  Fork activation defaults to MTP 1 (active
  19   *  from the start) with a reduced delay (1024 steps) so tests run fast.
  20   *  No pre-mined chain — use mineBlocks() if needed.
  21   */
  22  struct ForkTestingSetup : public TestingSetup {
  23      ForkTestingSetup(const TestOpts& opts = {})
  24          : TestingSetup(ChainType::FORK, {
  25              .extra_args = Cat(
  26                  std::vector<const char*>{
  27                      "-forkactivationtime=1",
  28                      "-forkdelaysteps=1024",
  29                  },
  30                  opts.extra_args),
  31              .coins_db_in_memory = opts.coins_db_in_memory,
  32              .block_tree_db_in_memory = opts.block_tree_db_in_memory,
  33              .setup_net = opts.setup_net,
  34              .setup_validation_interface = opts.setup_validation_interface,
  35              .min_validation_cache = opts.min_validation_cache,
  36          }) {}
  37  
  38      const Consensus::Params& ForkConsensus() const {
  39          return Params().GetConsensus();
  40      }
  41  };
  42  
  43  #endif // LIMENKA_TEST_FORK_UTIL_H
  44