Skip to content

Commit

Permalink
execute cron actor implicitly (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexytsu authored Oct 19, 2023
1 parent b136ad8 commit ef9e21e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion integration_tests/src/util/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions vm_api/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ pub fn apply_code<S: Serialize>(
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<S: Serialize>(
v: &dyn VM,
from: &Address,
to: &Address,
value: &TokenAmount,
method: MethodNum,
params: Option<S>,
) -> 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<T: DeserializeOwned>(v: &dyn VM, a: &Address) -> Option<T> {
let cid = v.actor(a).unwrap().state;
v.blockstore().get(&cid).unwrap().map(|slice| fvm_ipld_encoding::from_slice(&slice).unwrap())
Expand Down

0 comments on commit ef9e21e

Please sign in to comment.