|
| 1 | +use super::context::{SignerTestContext, SignerTestState}; |
| 2 | +use crate::tests::signer::v0::{get_chain_info_wrapper, MultipleMinerTest}; |
| 3 | +use madhouse::{Command, CommandWrapper}; |
| 4 | +use proptest::prelude::{Just, Strategy}; |
| 5 | +use std::sync::{Arc, Mutex}; |
| 6 | + |
| 7 | +pub struct BootToEpoch3 { |
| 8 | + miners: Arc<Mutex<MultipleMinerTest>>, |
| 9 | +} |
| 10 | + |
| 11 | +impl BootToEpoch3 { |
| 12 | + pub fn new(miners: Arc<Mutex<MultipleMinerTest>>) -> Self { |
| 13 | + Self { miners } |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +impl Command<SignerTestState, SignerTestContext> for BootToEpoch3 { |
| 18 | + fn check(&self, state: &SignerTestState) -> bool { |
| 19 | + println!( |
| 20 | + "Checking: Booting miners to Nakamoto. Result: {:?}", |
| 21 | + !state.is_booted_to_nakamoto |
| 22 | + ); |
| 23 | + !state.is_booted_to_nakamoto |
| 24 | + } |
| 25 | + |
| 26 | + fn apply(&self, state: &mut SignerTestState) { |
| 27 | + println!("Applying: Booting miners to Nakamoto"); |
| 28 | + |
| 29 | + self.miners.lock().unwrap().boot_to_epoch_3(); |
| 30 | + |
| 31 | + let (conf_1, _) = self.miners.lock().unwrap().get_node_configs(); |
| 32 | + let burn_block_height = get_chain_info_wrapper(&conf_1).burn_block_height; |
| 33 | + |
| 34 | + assert_eq!(burn_block_height, 231); |
| 35 | + |
| 36 | + state.is_booted_to_nakamoto = true; |
| 37 | + } |
| 38 | + |
| 39 | + fn label(&self) -> String { |
| 40 | + "BOOT_TO_EPOCH_3".to_string() |
| 41 | + } |
| 42 | + |
| 43 | + fn build( |
| 44 | + ctx: Arc<SignerTestContext>, |
| 45 | + ) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> { |
| 46 | + Just(CommandWrapper::new(BootToEpoch3::new(ctx.miners.clone()))) |
| 47 | + } |
| 48 | +} |
0 commit comments