Skip to content

Commit 8356158

Browse files
committed
runtime-sdk/testing: allow mock with custom keys
1 parent b0e9010 commit 8356158

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

runtime-sdk/src/testing/keymanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::{
1515

1616
#[derive(Default)]
1717
pub struct MockKeyManagerClient {
18-
keys: Mutex<HashMap<KeyPairId, KeyPair>>,
19-
ephemeral_keys: Mutex<HashMap<KeyPairId, KeyPair>>,
18+
pub keys: Mutex<HashMap<KeyPairId, KeyPair>>,
19+
pub ephemeral_keys: Mutex<HashMap<KeyPairId, KeyPair>>,
2020
}
2121

2222
impl Clone for MockKeyManagerClient {

runtime-sdk/src/testing/mock.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ impl Mock {
101101
)
102102
}
103103

104+
/// Create a new mock dispatch context.
105+
pub fn create_ctx_with_key_manager(&mut self, key_manager: Box<dyn KeyManager>) -> RuntimeBatchContext<'_, EmptyRuntime> {
106+
RuntimeBatchContext::new(
107+
&self.host_info,
108+
Some(key_manager),
109+
&self.runtime_header,
110+
&self.runtime_round_results,
111+
&self.consensus_state,
112+
&self.history,
113+
self.epoch,
114+
self.max_messages,
115+
)
116+
}
117+
104118
/// Create an instance with the given local configuration.
105119
pub fn with_local_config(local_config: BTreeMap<String, cbor::Value>) -> Self {
106120
// Ensure a current state is always available during tests. Note that one can always use a

0 commit comments

Comments
 (0)