| 25 | pub mod ipc; |
| 26 | |
| 27 | pub 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 | |
| 74 | pub struct Tester<I> { |
| 75 | interpreter: Arc<I>, |