From 84ee67b4330ad2536907ef486b590748614c8bb8 Mon Sep 17 00:00:00 2001 From: Alex Su Date: Wed, 18 Oct 2023 13:48:23 +1100 Subject: [PATCH] execute cron actor implicitly --- integration_tests/src/util/workflows.rs | 3 ++- vm_api/src/util/mod.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/integration_tests/src/util/workflows.rs b/integration_tests/src/util/workflows.rs index 3726bbabf..511b393c9 100644 --- a/integration_tests/src/util/workflows.rs +++ b/integration_tests/src/util/workflows.rs @@ -74,6 +74,7 @@ use fil_actors_runtime::VERIFIED_REGISTRY_ACTOR_ADDR; use fil_actors_runtime::{DATACAP_TOKEN_ACTOR_ID, VERIFIED_REGISTRY_ACTOR_ID}; use vm_api::trace::ExpectInvocation; use vm_api::util::apply_ok; +use vm_api::util::apply_ok_implicit; use vm_api::util::get_state; use vm_api::util::DynBlockstore; use vm_api::VM; @@ -86,7 +87,7 @@ use super::miner_dline_info; use super::sector_deadline; pub fn cron_tick(v: &dyn VM) { - apply_ok( + apply_ok_implicit( v, &SYSTEM_ACTOR_ADDR, &CRON_ACTOR_ADDR, diff --git a/vm_api/src/util/mod.rs b/vm_api/src/util/mod.rs index dde69bb79..463abe624 100644 --- a/vm_api/src/util/mod.rs +++ b/vm_api/src/util/mod.rs @@ -57,6 +57,21 @@ pub fn apply_code( assert_eq!(code, res.code, "expected code {}, got {} ({})", code, res.code, res.message); res.ret.map_or(RawBytes::default(), |b| RawBytes::new(b.data)) } + +pub fn apply_ok_implicit( + v: &dyn VM, + from: &Address, + to: &Address, + value: &TokenAmount, + method: MethodNum, + params: Option, +) -> RawBytes { + let code = ExitCode::OK; + let params = params.map(|p| IpldBlock::serialize_cbor(&p).unwrap().unwrap()); + let res = v.execute_message_implicit(from, to, value, method, params).unwrap(); + assert_eq!(code, res.code, "expected code {}, got {} ({})", code, res.code, res.message); + res.ret.map_or(RawBytes::default(), |b| RawBytes::new(b.data)) +} pub fn get_state(v: &dyn VM, a: &Address) -> Option { let cid = v.actor(a).unwrap().state; v.blockstore().get(&cid).unwrap().map(|slice| fvm_ipld_encoding::from_slice(&slice).unwrap())