From 05172950bc2108ef675331c1b3bb792a4e7892aa Mon Sep 17 00:00:00 2001 From: Alex Su Date: Wed, 11 Oct 2023 16:34:30 +1100 Subject: [PATCH] use implicit execution for cron_tick --- integration_tests/src/util/workflows.rs | 3 ++- vm_api/src/util/mod.rs | 27 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/integration_tests/src/util/workflows.rs b/integration_tests/src/util/workflows.rs index 3726bbabf4..511b393c9d 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 dde69bb795..19b065cdd7 100644 --- a/vm_api/src/util/mod.rs +++ b/vm_api/src/util/mod.rs @@ -57,6 +57,33 @@ 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 { + apply_code_implicit(v, from, to, value, method, params, ExitCode::OK) +} + +pub fn apply_code_implicit( + v: &dyn VM, + from: &Address, + to: &Address, + value: &TokenAmount, + method: MethodNum, + params: Option, + code: ExitCode, +) -> RawBytes { + 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())