Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions csnode/include/csnode/blockchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,13 @@ public slots:

static constexpr size_t kQuickStartSaveCachesInterval = 500'000;
std::chrono::steady_clock::time_point lastCheckpointWallClock_ = std::chrono::steady_clock::now();
int32_t blockRewardIntegral_;
uint64_t blockRewardFraction_ ;
int32_t miningCoefficientIntegral_;
uint64_t miningCoefficientFraction_;
bool stakingOn_;
bool miningOn_;
uint32_t TimeMinStage1_;
// consensus settings persisted in quick-start caches; same defaults as BlockChain_Serializer::clear()
int32_t blockRewardIntegral_ = 0;
uint64_t blockRewardFraction_ = 0;
int32_t miningCoefficientIntegral_ = 0;
uint64_t miningCoefficientFraction_ = 0;
bool stakingOn_ = false;
bool miningOn_ = false;
uint32_t TimeMinStage1_ = 500;
};
#endif // BLOCKCHAIN_HPP
14 changes: 14 additions & 0 deletions tests/csnode/blockchain_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ TEST(BlockChain, ContentEqualRequiresSameTrustedMask) {
canonical.add_real_trusted(cs::Utils::maskToBits(cs::Bytes{ 0, 255, 1 }));
ASSERT_FALSE(BlockChain::testContentEqual(own, canonical));
}

// these members are saved into quick-start caches and read back on the --set-bc-top path,
// possibly before any consensus-settings change has set them
TEST(BlockChain, ConsensusSettingsHaveDefinedDefaults) {
const csdb::Address genesis = csdb::Address::from_string("0000000000000000000000000000000000000000000000000000000000000001");
const csdb::Address start = csdb::Address::from_string("0000000000000000000000000000000000000000000000000000000000000002");
BlockChain blockChain(genesis, start);

ASSERT_TRUE(blockChain.getBlockReward() == csdb::Amount{ 0 });
ASSERT_TRUE(blockChain.getMiningCoefficient() == csdb::Amount{ 0 });
ASSERT_FALSE(blockChain.getMiningOn());
ASSERT_FALSE(blockChain.getStakingOn());
ASSERT_EQ(blockChain.getTimeMinStage1(), 500u);
}
Loading