Skip to content

Commit 62d38bc

Browse files
committed
fix: add epoch_205 test to verify that the new code that tracks which blocks contained epoch transitions works end-to-end
1 parent d8d25b8 commit 62d38bc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

testnet/stacks-node/src/tests/epoch_205.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::thread;
88
use stacks::burnchains::Burnchain;
99
use stacks::burnchains::Txid;
1010
use stacks::chainstate::burn::operations::BlockstackOperationType;
11+
use stacks::chainstate::stacks::db::StacksChainState;
1112
use stacks::chainstate::stacks::StacksPrivateKey;
1213
use stacks::chainstate::stacks::StacksTransaction;
1314
use stacks::chainstate::stacks::TransactionPayload;
@@ -17,6 +18,7 @@ use stacks::core::StacksEpochId;
1718
use stacks::types::chainstate::BlockHeaderHash;
1819
use stacks::types::chainstate::BurnchainHeaderHash;
1920
use stacks::types::chainstate::StacksAddress;
21+
use stacks::types::chainstate::StacksBlockHeader;
2022
use stacks::util::hash::hex_bytes;
2123
use stacks::vm::types::PrincipalData;
2224
use stacks::vm::ContractName;
@@ -235,6 +237,7 @@ fn test_exact_block_costs() {
235237
// check that we processed at least 32 transactions...
236238
// the reason not to do an exact check here is that there *is* some variability in microblock production,
237239
// so sometimes the miner doesn't produce a microblock
240+
eprintln!("Got {} total txs", total_txs);
238241
assert!(total_txs >= 32);
239242

240243
test_observer::clear();
@@ -520,6 +523,38 @@ fn transition_empty_blocks() {
520523
// also, make *huge* block-commits with invalid marker bytes once we reach the new
521524
// epoch, and verify that it fails.
522525
let tip_info = get_chain_info(&conf);
526+
527+
// this block is the epoch transition?
528+
let (chainstate, _) = StacksChainState::open(
529+
false,
530+
conf.burnchain.chain_id,
531+
&conf.get_chainstate_path_str(),
532+
)
533+
.unwrap();
534+
let res = StacksChainState::block_crosses_epoch_boundary(
535+
&chainstate.db(),
536+
&tip_info.stacks_tip_consensus_hash,
537+
&tip_info.stacks_tip,
538+
)
539+
.unwrap();
540+
debug!(
541+
"Epoch transition at {} ({}/{}) height {}: {}",
542+
&StacksBlockHeader::make_index_block_hash(
543+
&tip_info.stacks_tip_consensus_hash,
544+
&tip_info.stacks_tip
545+
),
546+
&tip_info.stacks_tip_consensus_hash,
547+
&tip_info.stacks_tip,
548+
tip_info.burn_block_height,
549+
res
550+
);
551+
552+
if tip_info.burn_block_height == epoch_2_05 {
553+
assert!(res);
554+
} else {
555+
assert!(!res);
556+
}
557+
523558
if tip_info.burn_block_height + 1 >= epoch_2_05 {
524559
let burn_fee_cap = 100000000; // 1 BTC
525560
let sunset_burn =

0 commit comments

Comments
 (0)