Skip to content

Commit 0eb69b7

Browse files
committed
fix test error
1 parent 3601def commit 0eb69b7

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tee-worker/sidechain/consensus/common/src/test/mocks/block_importer_mock.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,40 @@
1616
*/
1717

1818
use crate::{
19-
block_production_suspension::{BlockProductionSuspender, GLOBAL_BLOCK_SUSPENDER},
19+
block_production_suspension::{BlockProductionSuspender, SuspendBlockProductionTrait},
2020
test::mocks::verifier_mock::VerifierMock,
2121
BlockImport, Error, Result,
2222
};
2323
use core::marker::PhantomData;
2424
use itp_sgx_crypto::aes::Aes;
2525
use itp_sgx_externalities::SgxExternalities;
2626
use itp_test::mock::onchain_mock::OnchainMock;
27-
use itp_types::H256;
27+
use itp_types::{MrEnclave, H256};
2828
use its_primitives::traits::{ShardIdentifierFor, SignedBlock as SignedSidechainBlockTrait};
2929
use sp_core::Pair;
3030
use sp_runtime::traits::Block as ParentchainBlockTrait;
3131
use std::{collections::VecDeque, sync::RwLock};
3232

33+
pub struct MockBlockProductionSuspender;
34+
35+
impl SuspendBlockProductionTrait for MockBlockProductionSuspender {
36+
fn current_mr_enclave(&self) -> Result<MrEnclave> {
37+
Ok(Default::default())
38+
}
39+
40+
fn suspend_for_production(&self) -> Result<()> {
41+
Ok(())
42+
}
43+
44+
fn resume_for_production(&self) -> Result<()> {
45+
Ok(())
46+
}
47+
48+
fn is_production_suspended(&self) -> Result<bool> {
49+
Ok(false)
50+
}
51+
}
52+
3353
/// Block importer mock.
3454
pub struct BlockImportMock<ParentchainBlock, SignedSidechainBlock>
3555
where
@@ -99,7 +119,7 @@ where
99119
type SidechainState = SgxExternalities;
100120
type StateCrypto = Aes;
101121
type Context = OnchainMock;
102-
type BlockSuspender = BlockProductionSuspender;
122+
type BlockSuspender = MockBlockProductionSuspender;
103123

104124
fn verifier(
105125
&self,
@@ -131,7 +151,7 @@ where
131151
}
132152

133153
fn block_suspender(&self) -> Self::BlockSuspender {
134-
GLOBAL_BLOCK_SUSPENDER.clone()
154+
MockBlockProductionSuspender
135155
}
136156

137157
fn state_key(&self) -> Result<Self::StateCrypto> {

0 commit comments

Comments
 (0)