MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / init_exec_state

Function init_exec_state

fendermint/testing/contract-test/src/lib.rs:27–72  ·  view source on GitHub ↗
(
    multi_engine: Arc<MultiEngine>,
    genesis: Genesis,
)

Source from the content-addressed store, hash-verified

25pub mod ipc;
26
27pub async fn init_exec_state(
28 multi_engine: Arc<MultiEngine>,
29 genesis: Genesis,
30) -> anyhow::Result<(FvmExecState<MemoryBlockstore>, FvmGenesisOutput)> {
31 let bundle_path = bundle_path();
32 let bundle = std::fs::read(&bundle_path)
33 .with_context(|| format!("failed to read bundle: {}", bundle_path.to_string_lossy()))?;
34
35 let custom_actors_bundle_path = custom_actors_bundle_path();
36 let custom_actors_bundle = std::fs::read(&custom_actors_bundle_path).with_context(|| {
37 format!(
38 "failed to read custom actors_bundle: {}",
39 custom_actors_bundle_path.to_string_lossy()
40 )
41 })?;
42
43 let store = MemoryBlockstore::new();
44
45 let state = FvmGenesisState::new(store, multi_engine, &bundle, &custom_actors_bundle)
46 .await
47 .context("failed to create state")?;
48
49 let (client, _) =
50 tendermint_rpc::MockClient::new(tendermint_rpc::MockRequestMethodMatcher::default());
51
52 let interpreter = FvmMessageInterpreter::new(
53 client,
54 None,
55 contracts_path(),
56 1.05,
57 1.05,
58 false,
59 UpgradeScheduler::new(),
60 );
61
62 let (state, out) = interpreter
63 .init(state, genesis)
64 .await
65 .context("failed to create actors")?;
66
67 let state = state
68 .into_exec_state()
69 .map_err(|_| anyhow!("should be in exec stage"))?;
70
71 Ok((state, out))
72}
73
74pub struct Tester<I> {
75 interpreter: Arc<I>,

Callers 1

new_systemMethod · 0.85

Calls 7

bundle_pathFunction · 0.85
with_contextMethod · 0.80
contextMethod · 0.80
into_exec_stateMethod · 0.80
contracts_pathFunction · 0.50
initMethod · 0.45

Tested by 1

new_systemMethod · 0.68