diff --git a/state/src/check.rs b/state/src/check.rs index c0c06405a..2988e7b22 100644 --- a/state/src/check.rs +++ b/state/src/check.rs @@ -1,8 +1,8 @@ +use std::collections::BTreeMap; use std::collections::HashMap; use std::fmt::Debug; use anyhow::bail; -use bimap::BiBTreeMap; use cid::Cid; use fil_actor_account::State as AccountState; use fil_actor_cron::State as CronState; @@ -114,7 +114,7 @@ macro_rules! get_state { // It could be replaced with a custom mapping trait (while Rust doesn't support // abstract collection traits). pub fn check_state_invariants( - manifest: &BiBTreeMap, + manifest: &BTreeMap, policy: &Policy, tree: Tree<'_, BS>, expected_balance_total: &TokenAmount, @@ -143,7 +143,7 @@ pub fn check_state_invariants( } total_fil += &actor.balance; - match manifest.get_by_left(&actor.code) { + match manifest.get(&actor.code) { Some(Type::System) => (), Some(Type::Init) => { let state = get_state!(tree, actor, InitState); diff --git a/test_vm/src/lib.rs b/test_vm/src/lib.rs index 42887e669..0162071c0 100644 --- a/test_vm/src/lib.rs +++ b/test_vm/src/lib.rs @@ -1,6 +1,5 @@ use crate::fakes::FakePrimitives; use anyhow::anyhow; -use bimap::BiBTreeMap; use cid::multihash::Code; use cid::Cid; use fil_actor_account::{Actor as AccountActor, State as AccountState}; @@ -36,7 +35,6 @@ use fil_builtin_actors_state::check::Tree; use fvm_ipld_blockstore::Blockstore; use fvm_ipld_blockstore::MemoryBlockstore; use fvm_ipld_encoding::ipld_block::IpldBlock; -use fvm_ipld_encoding::tuple::*; use fvm_ipld_encoding::CborStore; use fvm_ipld_hamt::{BytesKey, Hamt, Sha256}; use fvm_shared::address::Address; @@ -67,9 +65,7 @@ use regex::Regex; use serde::de::DeserializeOwned; use serde::{ser, Serialize}; use std::cell::{RefCell, RefMut}; -use std::collections::HashMap; -use std::error::Error; -use std::fmt; +use std::collections::{BTreeMap, HashMap}; use std::ops::Add; use trace::InvocationTrace; @@ -82,57 +78,8 @@ pub mod fakes; pub mod trace; pub mod util; -/// An abstract VM that is injected into integration tests -pub trait VM { - /// Returns the underlying blockstore of the VM - fn blockstore(&self) -> &dyn Blockstore; - - /// Get the state root of the specified actor - fn actor_root(&self, address: &Address) -> Option; - - /// Get the current chain epoch - fn epoch(&self) -> ChainEpoch; - - /// Get the balance of the specified actor - fn balance(&self, address: &Address) -> TokenAmount; - - /// Get the ID for the specified address - fn resolve_id_address(&self, address: &Address) -> Option
; - - /// Send a message between the two specified actors - fn execute_message( - &self, - from: &Address, - to: &Address, - value: &TokenAmount, - method: MethodNum, - params: Option, - ) -> Result; - - /// Sets the epoch to the specified value - fn set_epoch(&self, epoch: ChainEpoch); - - /// Take all the invocations that have been made since the last call to this method - fn take_invocations(&self) -> Vec; - - /// Get information about an actor - fn actor(&self, address: &Address) -> Option; - - /// Build a map of all actors in the system and their type - fn actor_manifest(&self) -> BiBTreeMap; - - /// Provides access to VM primitives - fn primitives(&self) -> &dyn Primitives; - - /// Get the current runtime policy - fn policy(&self) -> Policy; - - /// Get the root Cid of the state tree - fn state_root(&self) -> Cid; - - /// Get the total amount of FIL in circulation - fn total_fil(&self) -> TokenAmount; -} +mod vm; +pub use vm::*; /// An in-memory rust-execution VM for testing that yields sensible stack traces and debug info pub struct TestVM<'bs, BS> @@ -142,9 +89,9 @@ where pub primitives: FakePrimitives, pub store: &'bs BS, pub state_root: RefCell, - total_fil: TokenAmount, + circulating_supply: RefCell, actors_dirty: RefCell, - actors_cache: RefCell>, + actors_cache: RefCell>, network_version: NetworkVersion, curr_epoch: RefCell, invocations: RefCell>, @@ -205,11 +152,11 @@ where value: &TokenAmount, method: MethodNum, params: Option, - ) -> Result { + ) -> Result { let from_id = &self.resolve_id_address(from).unwrap(); let mut a = self.get_actor(from_id).unwrap(); - let call_seq = a.call_seq_num; - a.call_seq_num = call_seq + 1; + let call_seq = a.call_seq; + a.call_seq = call_seq + 1; // EthAccount abstractions turns Placeholders into EthAccounts if a.code == *PLACEHOLDER_ACTOR_CODE_ID { a.code = *ETHACCOUNT_ACTOR_CODE_ID; @@ -260,12 +207,16 @@ where } } - fn actor_root(&self, address: &Address) -> Option { - let a_opt = self.get_actor(address); - let a = a_opt.as_ref()?; - Some(a.head) + fn execute_message_implicit( + &self, + from: &Address, + to: &Address, + value: &TokenAmount, + method: MethodNum, + params: Option, + ) -> Result { + self.execute_message(from, to, value, method, params) } - fn resolve_id_address(&self, address: &Address) -> Option
{ let st: InitState = get_state(self, &INIT_ACTOR_ADDR).unwrap(); st.resolve_address::(self.store, address).unwrap() @@ -284,15 +235,17 @@ where self.invocations.take() } - fn actor(&self, address: &Address) -> Option { + fn actor(&self, address: &Address) -> Option { // check for inclusion in cache of changed actors if let Some(act) = self.actors_cache.borrow().get(address) { return Some(act.clone()); } // go to persisted map - let actors = - Hamt::<&'bs BS, Actor, BytesKey, Sha256>::load(&self.state_root.borrow(), self.store) - .unwrap(); + let actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load( + &self.state_root.borrow(), + self.store, + ) + .unwrap(); let actor = actors.get(&address.to_bytes()).unwrap().cloned(); actor.iter().for_each(|a| { self.actors_cache.borrow_mut().insert(*address, a.clone()); @@ -300,34 +253,24 @@ where actor } - fn actor_manifest(&self) -> BiBTreeMap { - let actors = - Hamt::<&'bs BS, Actor, BytesKey, Sha256>::load(&self.state_root.borrow(), self.store) - .unwrap(); - let mut manifest = BiBTreeMap::new(); - actors - .for_each(|_, actor| { - manifest.insert(actor.code, ACTOR_TYPES.get(&actor.code).unwrap().to_owned()); - Ok(()) - }) - .unwrap(); - manifest + fn primitives(&self) -> &dyn Primitives { + &self.primitives } - fn policy(&self) -> Policy { - Policy::default() + fn actor_manifest(&self) -> BTreeMap { + ACTOR_TYPES.clone() } fn state_root(&self) -> Cid { *self.state_root.borrow() } - fn total_fil(&self) -> TokenAmount { - self.total_fil.clone() + fn circulating_supply(&self) -> TokenAmount { + self.circulating_supply.borrow().clone() } - fn primitives(&self) -> &dyn Primitives { - &self.primitives + fn set_circulating_supply(&self, supply: TokenAmount) { + self.circulating_supply.replace(supply); } } @@ -336,12 +279,12 @@ where BS: Blockstore, { pub fn new(store: &'bs MemoryBlockstore) -> TestVM<'bs, MemoryBlockstore> { - let mut actors = Hamt::<&'bs MemoryBlockstore, Actor, BytesKey, Sha256>::new(store); + let mut actors = Hamt::<&'bs MemoryBlockstore, ActorState, BytesKey, Sha256>::new(store); TestVM { primitives: FakePrimitives {}, store, state_root: RefCell::new(actors.flush().unwrap()), - total_fil: TokenAmount::zero(), + circulating_supply: RefCell::new(TokenAmount::zero()), actors_dirty: RefCell::new(false), actors_cache: RefCell::new(HashMap::new()), network_version: NetworkVersion::V16, @@ -350,16 +293,12 @@ where } } - pub fn with_total_fil(self, total_fil: TokenAmount) -> Self { - Self { total_fil, ..self } - } - pub fn new_with_singletons(store: &'bs MemoryBlockstore) -> TestVM<'bs, MemoryBlockstore> { let reward_total = TokenAmount::from_whole(1_100_000_000i64); let faucet_total = TokenAmount::from_whole(1_000_000_000i64); - let v = TestVM::<'_, MemoryBlockstore>::new(store) - .with_total_fil(&reward_total + &faucet_total); + let v = TestVM::<'_, MemoryBlockstore>::new(store); + v.set_circulating_supply(&reward_total + &faucet_total); // system let sys_st = SystemState::new(store).unwrap(); @@ -504,7 +443,7 @@ where primitives: FakePrimitives {}, store: self.store, state_root: self.state_root.clone(), - total_fil: self.total_fil, + circulating_supply: self.circulating_supply, actors_dirty: RefCell::new(false), actors_cache: RefCell::new(HashMap::new()), network_version: self.network_version, @@ -520,15 +459,17 @@ where self.store.put_cbor(obj, Code::Blake2b256).unwrap() } - pub fn get_actor(&self, addr: &Address) -> Option { + pub fn get_actor(&self, addr: &Address) -> Option { // check for inclusion in cache of changed actors if let Some(act) = self.actors_cache.borrow().get(addr) { return Some(act.clone()); } // go to persisted map - let actors = - Hamt::<&'bs BS, Actor, BytesKey, Sha256>::load(&self.state_root.borrow(), self.store) - .unwrap(); + let actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load( + &self.state_root.borrow(), + self.store, + ) + .unwrap(); let actor = actors.get(&addr.to_bytes()).unwrap().cloned(); actor.iter().for_each(|a| { self.actors_cache.borrow_mut().insert(*addr, a.clone()); @@ -537,16 +478,18 @@ where } // blindly overwrite the actor at this address whether it previously existed or not - pub fn set_actor(&self, key: &Address, a: Actor) { + pub fn set_actor(&self, key: &Address, a: ActorState) { self.actors_cache.borrow_mut().insert(*key, a); self.actors_dirty.replace(true); } pub fn checkpoint(&self) -> Cid { // persist cache on top of latest checkpoint and clear - let mut actors = - Hamt::<&'bs BS, Actor, BytesKey, Sha256>::load(&self.state_root.borrow(), self.store) - .unwrap(); + let mut actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load( + &self.state_root.borrow(), + self.store, + ) + .unwrap(); for (addr, act) in self.actors_cache.borrow().iter() { actors.set(addr.to_bytes().into(), act.clone()).unwrap(); } @@ -568,9 +511,9 @@ where F: FnOnce(&mut S), { let mut a = self.get_actor(addr).unwrap(); - let mut st = self.store.get_cbor::(&a.head).unwrap().unwrap(); + let mut st = self.store.get_cbor::(&a.state).unwrap().unwrap(); f(&mut st); - a.head = self.store.put_cbor(&st, Code::Blake2b256).unwrap(); + a.state = self.store.put_cbor(&st, Code::Blake2b256).unwrap(); self.set_actor(addr, a); } @@ -654,7 +597,10 @@ impl<'invocation, 'bs, BS> InvocationCtx<'invocation, 'bs, BS> where BS: Blockstore, { - fn resolve_target(&'invocation self, target: &Address) -> Result<(Actor, Address), ActorError> { + fn resolve_target( + &'invocation self, + target: &Address, + ) -> Result<(ActorState, Address), ActorError> { if let Some(a) = self.v.resolve_id_address(target) { if let Some(act) = self.v.get_actor(&a) { return Ok((act, a)); @@ -692,7 +638,7 @@ where assert!(!existing, "should never have existing actor when no f4 address is specified"); let target_id_addr = Address::new_id(target_id); let mut init_actor = self.v.get_actor(&INIT_ACTOR_ADDR).unwrap(); - init_actor.head = self.v.store.put_cbor(&st, Code::Blake2b256).unwrap(); + init_actor.state = self.v.store.put_cbor(&st, Code::Blake2b256).unwrap(); self.v.set_actor(&INIT_ACTOR_ADDR, init_actor); let new_actor_msg = InternalMessage { @@ -1078,7 +1024,7 @@ where } fn get_state_root(&self) -> Result { - Ok(self.v.get_actor(&self.to()).unwrap().head) + Ok(self.v.get_actor(&self.to()).unwrap().state) } fn set_state_root(&self, root: &Cid) -> Result<(), ActorError> { @@ -1089,7 +1035,7 @@ where "actor does not exist".to_string(), )), Some(mut act) if !self.read_only() => { - act.head = *root; + act.state = *root; self.v.set_actor(&self.to(), act); Ok(()) } @@ -1111,7 +1057,7 @@ where self.allow_side_effects.replace(true); let ret = result?; let mut act = self.v.get_actor(&self.to()).unwrap(); - act.head = self.v.store.put_cbor(&st, Code::Blake2b256).unwrap(); + act.state = self.v.store.put_cbor(&st, Code::Blake2b256).unwrap(); if self.read_only { return Err(ActorError::unchecked( @@ -1279,49 +1225,3 @@ pub struct MessageResult { pub message: String, pub ret: Option, } - -#[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] -pub struct Actor { - pub code: Cid, - pub head: Cid, - pub call_seq_num: u64, - pub balance: TokenAmount, - pub predictable_address: Option
, -} - -pub fn actor( - code: Cid, - head: Cid, - call_seq_num: u64, - balance: TokenAmount, - predictable_address: Option
, -) -> Actor { - Actor { code, head, call_seq_num, balance, predictable_address } -} - -#[derive(Debug)] -pub struct TestVMError { - msg: String, -} - -impl fmt::Display for TestVMError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.msg) - } -} - -impl Error for TestVMError { - fn description(&self) -> &str { - &self.msg - } -} - -impl From for TestVMError { - fn from(h_err: fvm_ipld_hamt::Error) -> Self { - vm_err(h_err.to_string().as_str()) - } -} - -pub fn vm_err(msg: &str) -> TestVMError { - TestVMError { msg: msg.to_string() } -} diff --git a/test_vm/src/util/mod.rs b/test_vm/src/util/mod.rs index fb175c48a..5052ddf6f 100644 --- a/test_vm/src/util/mod.rs +++ b/test_vm/src/util/mod.rs @@ -620,7 +620,7 @@ where } pub fn get_state(v: &dyn VM, a: &Address) -> Option { - let cid = v.actor_root(a).unwrap(); + let cid = v.actor(a).unwrap().state; v.blockstore().get(&cid).unwrap().map(|slice| fvm_ipld_encoding::from_slice(&slice).unwrap()) } @@ -783,22 +783,22 @@ pub fn change_beneficiary( ); } -pub fn check_invariants(vm: &dyn VM) -> anyhow::Result { +pub fn check_invariants(vm: &dyn VM, policy: &Policy) -> anyhow::Result { check_state_invariants( &vm.actor_manifest(), - &vm.policy(), + policy, Tree::load(&DynBlockstore::wrap(vm.blockstore()), &vm.state_root()).unwrap(), - &vm.total_fil(), + &vm.circulating_supply(), vm.epoch() - 1, ) } -pub fn assert_invariants(vm: &dyn VM) { - check_invariants(vm).unwrap().assert_empty() +pub fn assert_invariants(v: &dyn VM, policy: &Policy) { + check_invariants(v, policy).unwrap().assert_empty() } -pub fn expect_invariants(vm: &dyn VM, expected_patterns: &[Regex]) { - check_invariants(vm).unwrap().assert_expected(expected_patterns) +pub fn expect_invariants(v: &dyn VM, policy: &Policy, expected_patterns: &[Regex]) { + check_invariants(v, policy).unwrap().assert_expected(expected_patterns) } pub fn get_network_stats(vm: &dyn VM) -> NetworkStats { diff --git a/test_vm/src/vm.rs b/test_vm/src/vm.rs new file mode 100644 index 000000000..98c941791 --- /dev/null +++ b/test_vm/src/vm.rs @@ -0,0 +1,122 @@ +/*! + * The VM module is replicated in this code tree temporarily. This is the high-level abstract interface + * for a virtual-machine that can execute Filecoin WASM actors. It defines the high-level virtual-machine + * interface, associated error and trace types and an interface to inject/override the behaviour of + * certain primitives for the purpose of running tests. + * + * TODO(alexytsu): It should eventually be moved to an external location so that it can be shared + * with the anorth/fvm-workbench implementation + */ +use std::{collections::BTreeMap, error::Error, fmt}; + +use cid::Cid; +use fil_actors_runtime::runtime::{builtins::Type, Primitives}; +use fvm_ipld_blockstore::Blockstore; +use fvm_ipld_encoding::{ + ipld_block::IpldBlock, + tuple::{serde_tuple, Deserialize_tuple, Serialize_tuple}, +}; +use fvm_shared::{address::Address, clock::ChainEpoch, econ::TokenAmount, MethodNum}; + +use crate::{trace::InvocationTrace, MessageResult}; + +/// An abstract VM that is injected into integration tests +pub trait VM { + /// Returns the underlying blockstore of the VM + fn blockstore(&self) -> &dyn Blockstore; + + /// Get the current chain epoch + fn epoch(&self) -> ChainEpoch; + + /// Sets the epoch to the specified value + fn set_epoch(&self, epoch: ChainEpoch); + + /// Get information about an actor + fn actor(&self, address: &Address) -> Option; + + /// Get the balance of the specified actor + fn balance(&self, address: &Address) -> TokenAmount; + + /// Get the ID for the specified address + fn resolve_id_address(&self, address: &Address) -> Option
; + + /// Send a message between the two specified actors + fn execute_message( + &self, + from: &Address, + to: &Address, + value: &TokenAmount, + method: MethodNum, + params: Option, + ) -> Result; + + /// Send a message without charging gas + fn execute_message_implicit( + &self, + from: &Address, + to: &Address, + value: &TokenAmount, + method: MethodNum, + params: Option, + ) -> Result; + + /// Take all the invocations that have been made since the last call to this method + fn take_invocations(&self) -> Vec; + + fn set_circulating_supply(&self, supply: TokenAmount); + + fn circulating_supply(&self) -> TokenAmount; + + /// Provides access to VM primitives + fn primitives(&self) -> &dyn Primitives; + + fn actor_manifest(&self) -> BTreeMap; + + fn state_root(&self) -> Cid; +} + +#[derive(Debug)] +pub struct VMError { + msg: String, +} + +impl fmt::Display for VMError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.msg) + } +} + +impl Error for VMError { + fn description(&self) -> &str { + &self.msg + } +} + +impl From for VMError { + fn from(h_err: fvm_ipld_hamt::Error) -> Self { + vm_err(h_err.to_string().as_str()) + } +} + +pub fn vm_err(msg: &str) -> VMError { + VMError { msg: msg.to_string() } +} + +#[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] +pub struct ActorState { + pub code: Cid, + pub state: Cid, + pub call_seq: u64, + pub balance: TokenAmount, + pub predictable_address: Option
, +} + +pub fn actor( + code: Cid, + head: Cid, + call_seq_num: u64, + balance: TokenAmount, + predictable_address: Option
, +) -> ActorState { + ActorState { code, state: head, call_seq: call_seq_num, balance, predictable_address } +} diff --git a/test_vm/tests/batch_onboarding.rs b/test_vm/tests/batch_onboarding.rs index 59341c2e4..9a68995b2 100644 --- a/test_vm/tests/batch_onboarding.rs +++ b/test_vm/tests/batch_onboarding.rs @@ -6,6 +6,7 @@ use fil_actors_runtime::runtime::policy::policy_constants::PRE_COMMIT_CHALLENGE_ use fil_actors_runtime::runtime::policy_constants::{ MAX_AGGREGATED_SECTORS, PRE_COMMIT_SECTOR_BATCH_MAX_SIZE, }; +use fil_actors_runtime::runtime::Policy; use fil_actors_runtime::CRON_ACTOR_ADDR; use fvm_ipld_blockstore::MemoryBlockstore; use fvm_ipld_encoding::RawBytes; @@ -167,5 +168,9 @@ pub fn batch_onboarding_test(v: &dyn VM, v2: bool) { ); assert!(network_stats.total_pledge_collateral.is_positive()); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } diff --git a/test_vm/tests/change_beneficiary_test.rs b/test_vm/tests/change_beneficiary_test.rs index ef7e40f29..1537484b0 100644 --- a/test_vm/tests/change_beneficiary_test.rs +++ b/test_vm/tests/change_beneficiary_test.rs @@ -1,6 +1,7 @@ use fil_actor_miner::{ ActiveBeneficiary, ChangeBeneficiaryParams, Method as MinerMethod, PendingBeneficiaryChange, }; +use fil_actors_runtime::runtime::Policy; use fvm_ipld_blockstore::MemoryBlockstore; use fvm_shared::bigint::Zero; use fvm_shared::econ::TokenAmount; @@ -71,7 +72,7 @@ fn change_beneficiary_success_test(v: &dyn VM) { get_beneficiary_return = get_beneficiary(v, &query_addr, &miner_id); assert!(get_beneficiary_return.proposed.is_none()); assert_active(&change_another_beneificiary_proposal, &get_beneficiary_return.active); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } #[test] @@ -235,7 +236,7 @@ fn change_beneficiary_fail_test(v: &dyn VM) { change_beneficiary(v, &owner, &miner_id, &back_owner_proposal); change_beneficiary(v, &beneficiary, &miner_id, &back_owner_proposal); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } fn assert_pending( diff --git a/test_vm/tests/change_owner_test.rs b/test_vm/tests/change_owner_test.rs index 659ff1b06..d9e41d3ef 100644 --- a/test_vm/tests/change_owner_test.rs +++ b/test_vm/tests/change_owner_test.rs @@ -1,4 +1,5 @@ use fil_actor_miner::{ChangeBeneficiaryParams, Method as MinerMethod}; +use fil_actors_runtime::runtime::Policy; use fvm_ipld_blockstore::MemoryBlockstore; use fvm_shared::bigint::Zero; use fvm_shared::econ::TokenAmount; @@ -48,7 +49,7 @@ fn change_owner_success_test(v: &dyn VM) { assert_eq!(new_owner, minfo.owner); assert_eq!(new_owner, minfo.beneficiary); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -94,7 +95,7 @@ fn keep_beneficiary_when_owner_changed_test(v: &dyn VM) { assert_eq!(new_owner, minfo.owner); assert_eq!(beneficiary, minfo.beneficiary); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -171,5 +172,5 @@ fn change_owner_fail_test(v: &dyn VM) { assert_eq!(addr, minfo.owner); assert_eq!(addr, minfo.beneficiary); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } diff --git a/test_vm/tests/commit_post_test.rs b/test_vm/tests/commit_post_test.rs index b3de63e16..bdbeb9fa6 100644 --- a/test_vm/tests/commit_post_test.rs +++ b/test_vm/tests/commit_post_test.rs @@ -181,7 +181,7 @@ fn submit_post_succeeds_test(v: &dyn VM, miner_info: MinerInfo, sector_info: Sec let p_st: PowerState = get_state(v, &STORAGE_POWER_ACTOR_ADDR).unwrap(); assert_eq!(sector_power.raw, p_st.total_bytes_committed); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } #[test] @@ -226,7 +226,7 @@ fn skip_sector_test(v: &dyn VM, sector_info: SectorInfo, miner_info: MinerInfo) let network_stats = get_network_stats(v); assert!(network_stats.total_bytes_committed.is_zero()); assert!(network_stats.total_pledge_collateral.is_positive()); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -289,7 +289,11 @@ fn missed_first_post_deadline_test(v: &dyn VM, sector_info: SectorInfo, miner_in assert!(network_stats.total_bytes_committed.is_zero()); assert!(network_stats.total_pledge_collateral.is_positive()); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -397,7 +401,11 @@ fn overdue_precommit_test(v: &dyn VM) { assert!(network_stats.total_raw_byte_power.is_zero()); assert!(network_stats.total_quality_adj_power.is_zero()); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -470,7 +478,11 @@ fn aggregate_bad_sector_number_test(v: &dyn VM) { Some(params), ExitCode::USR_ILLEGAL_ARGUMENT, ); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -575,7 +587,11 @@ fn aggregate_size_limits_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -644,7 +660,11 @@ fn aggregate_bad_sender_test(v: &dyn VM) { Some(params), ExitCode::USR_FORBIDDEN, ); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -763,5 +783,9 @@ fn aggregate_one_precommit_expires_test(v: &dyn VM) { assert!(balances.initial_pledge.is_positive()); assert!(balances.pre_commit_deposit.is_positive()); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } diff --git a/test_vm/tests/extend_sectors_test.rs b/test_vm/tests/extend_sectors_test.rs index 78806e050..48f2a1d65 100644 --- a/test_vm/tests/extend_sectors_test.rs +++ b/test_vm/tests/extend_sectors_test.rs @@ -333,7 +333,11 @@ fn extend_legacy_sector_with_deals_inner( // 1/2 * 2/3 -> 1/3 assert_eq!(initial_verified_deal_weight / 3, sector_info.verified_deal_weight); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] diff --git a/test_vm/tests/init_test.rs b/test_vm/tests/init_test.rs index 68702b576..70fb2efec 100644 --- a/test_vm/tests/init_test.rs +++ b/test_vm/tests/init_test.rs @@ -12,7 +12,7 @@ use test_vm::{actor, util::serialize_ok, TestVM, FIRST_TEST_USER_ADDR, TEST_FAUC fn assert_placeholder_actor(exp_bal: TokenAmount, v: &dyn VM, addr: Address) { let act = v.actor(&addr).unwrap(); - assert_eq!(EMPTY_ARR_CID, act.head); + assert_eq!(EMPTY_ARR_CID, act.state); assert_eq!(*PLACEHOLDER_ACTOR_CODE_ID, act.code); assert_eq!(exp_bal, act.balance); } diff --git a/test_vm/tests/market_miner_withdrawal_test.rs b/test_vm/tests/market_miner_withdrawal_test.rs index 7ab0ba046..96dabce26 100644 --- a/test_vm/tests/market_miner_withdrawal_test.rs +++ b/test_vm/tests/market_miner_withdrawal_test.rs @@ -14,7 +14,7 @@ use fvm_shared::error::ExitCode; use fvm_shared::sector::RegisteredPoStProof; use fvm_shared::METHOD_SEND; use test_vm::util::{apply_code, apply_ok, create_accounts, create_miner}; -use test_vm::Actor; +use test_vm::ActorState; use test_vm::TestVM; use test_vm::VM; @@ -254,7 +254,7 @@ fn assert_add_collateral_and_withdraw( assert_eq!(caller_initial_balance, c.balance); } -fn require_actor(v: &dyn VM, addr: Address) -> Actor { +fn require_actor(v: &dyn VM, addr: Address) -> ActorState { v.actor(&addr).unwrap() } diff --git a/test_vm/tests/multisig_test.rs b/test_vm/tests/multisig_test.rs index d96503179..525768b1b 100644 --- a/test_vm/tests/multisig_test.rs +++ b/test_vm/tests/multisig_test.rs @@ -4,6 +4,7 @@ use fil_actor_multisig::{ State as MsigState, SwapSignerParams, Transaction, TxnID, TxnIDParams, }; use fil_actors_runtime::cbor::serialize; +use fil_actors_runtime::runtime::Policy; use fil_actors_runtime::test_utils::*; use fil_actors_runtime::{make_map_with_root, INIT_ACTOR_ADDR, SYSTEM_ACTOR_ADDR}; use fvm_ipld_blockstore::MemoryBlockstore; @@ -27,17 +28,15 @@ use test_vm::{TestVM, VM}; fn proposal_hash() { let store = MemoryBlockstore::new(); let v = TestVM::::new_with_singletons(&store); - let addrs = create_accounts(&v, 3, &TokenAmount::from_whole(10_000)); - let sys_act_start_bal = v.get_actor(&SYSTEM_ACTOR_ADDR).unwrap().balance; - let fil_delta = proposal_hash_test(&v, &addrs); - assert_eq!(sys_act_start_bal + fil_delta, v.get_actor(&SYSTEM_ACTOR_ADDR).unwrap().balance); - assert_invariants(&v) + proposal_hash_test(&v); } -fn proposal_hash_test(v: &dyn VM, addrs: &[Address]) -> TokenAmount { +fn proposal_hash_test(v: &dyn VM) { + let addrs = create_accounts(v, 3, &TokenAmount::from_whole(10_000)); + let sys_act_start_bal = v.actor(&SYSTEM_ACTOR_ADDR).unwrap().balance; let alice = addrs[0]; let bob = addrs[1]; - let msig_addr = create_msig(v, addrs, 2); + let msig_addr = create_msig(v, &addrs, 2); // fund msig and propose send funds to system actor let fil_delta = TokenAmount::from_nano(3); @@ -108,7 +107,9 @@ fn proposal_hash_test(v: &dyn VM, addrs: &[Address]) -> TokenAmount { ..Default::default() }; expect.matches(v.take_invocations().last().unwrap()); - fil_delta + + assert_eq!(sys_act_start_bal + fil_delta, v.actor(&SYSTEM_ACTOR_ADDR).unwrap().balance); + assert_invariants(v, &Policy::default()) } #[test] @@ -176,7 +177,7 @@ fn test_delete_self() { let new_signers: HashSet
= HashSet::from_iter(st.signers); let diff: Vec<&Address> = old_signers.symmetric_difference(&new_signers).collect(); assert_eq!(vec![&(addrs[remove_idx])], diff); - assert_invariants(&v) + assert_invariants(&v, &Policy::default()) }; test(2, 3, 0); // 2 of 3 removed is proposer test(2, 3, 1); // 2 of 3 removed is approver @@ -213,7 +214,7 @@ fn swap_self_1_of_2_test(v: &dyn VM) { ); let st: MsigState = get_state(v, &msig_addr).unwrap(); assert_eq!(vec![bob, chuck], st.signers); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } #[test] @@ -291,7 +292,7 @@ fn swap_self_2_of_3_test(v: &dyn VM) { let st: MsigState = get_state(v, &msig_addr).unwrap(); assert_eq!(vec![bob, chuck, alice], st.signers); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } fn create_msig(v: &dyn VM, signers: &[Address], threshold: u64) -> Address { diff --git a/test_vm/tests/power_scenario_tests.rs b/test_vm/tests/power_scenario_tests.rs index e46269786..332ae6fb6 100644 --- a/test_vm/tests/power_scenario_tests.rs +++ b/test_vm/tests/power_scenario_tests.rs @@ -102,7 +102,7 @@ fn power_create_miner_test(v: &dyn VM) { }; expect.matches(v.take_invocations().last().unwrap()); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } #[test] @@ -215,5 +215,9 @@ fn test_cron_tick() { } .matches(v.take_invocations().first().unwrap()); - expect_invariants(&v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + &v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } diff --git a/test_vm/tests/publish_deals_test.rs b/test_vm/tests/publish_deals_test.rs index 37b3f6c11..c601685b0 100644 --- a/test_vm/tests/publish_deals_test.rs +++ b/test_vm/tests/publish_deals_test.rs @@ -145,7 +145,7 @@ fn psd_mismatched_provider_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 2], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -173,7 +173,7 @@ fn psd_bad_piece_size_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![1], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -195,7 +195,7 @@ fn psd_start_time_in_past_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![1], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -216,7 +216,7 @@ fn psd_client_address_cannot_be_resolved_test(v: &dyn VM, a: Addrs, deal_start: let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -236,7 +236,7 @@ fn psd_no_client_lockup_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![1], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -272,7 +272,7 @@ fn psd_not_enough_client_lockup_for_batch_test(v: &dyn VM, a: Addrs, deal_start: let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -314,7 +314,7 @@ fn psd_not_enough_provider_lockup_for_batch_test(v: &dyn VM, deal_start: i64, a: let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -346,7 +346,7 @@ fn psd_duplicate_deal_in_batch_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 1, 4], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -376,7 +376,7 @@ fn psd_duplicate_deal_in_state_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs2 = bf_all(deal_ret2.valid_deals); assert_eq!(vec![1], good_inputs2); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -408,7 +408,7 @@ fn psd_verified_deal_fails_getting_datacap_test(v: &dyn VM, a: Addrs, deal_start let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 1], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -471,7 +471,7 @@ fn psd_random_assortment_of_failures_test(v: &dyn VM, a: Addrs, deal_start: i64) let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 2, 8], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -501,7 +501,7 @@ fn psd_all_deals_are_bad_test(v: &dyn VM, a: Addrs, deal_start: i64) { ); batcher.publish_fail(a.worker); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -579,7 +579,7 @@ fn psd_bad_sig_test(v: &dyn VM, a: Addrs, deal_start: i64) { } .matches(v.take_invocations().last().unwrap()); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -604,7 +604,7 @@ fn all_deals_are_good_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 1, 2, 3, 4], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -635,7 +635,7 @@ fn psd_valid_deals_with_ones_longer_than_540_test(v: &dyn VM, a: Addrs, deal_sta let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 1, 2], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -668,5 +668,5 @@ fn psd_deal_duration_too_long_test(v: &dyn VM, a: Addrs, deal_start: i64) { let good_inputs = bf_all(deal_ret.valid_deals); assert_eq!(vec![0, 1], good_inputs); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } diff --git a/test_vm/tests/replica_update_test.rs b/test_vm/tests/replica_update_test.rs index 6fb2e3eda..4046d73c9 100644 --- a/test_vm/tests/replica_update_test.rs +++ b/test_vm/tests/replica_update_test.rs @@ -48,7 +48,10 @@ use test_vm::TestVM; #[test_case(false; "v1")] #[test_case(true; "v2")] fn replica_update_simple_path_success(v2: bool) { - assert_invariants(&create_miner_and_upgrade_sector(&MemoryBlockstore::new(), v2).0); + assert_invariants( + &create_miner_and_upgrade_sector(&MemoryBlockstore::new(), v2).0, + &Policy::default(), + ); } // Tests a successful upgrade, followed by the sector going faulty and recovering @@ -126,7 +129,7 @@ fn replica_update_full_path_success_test( assert!(!check_sector_faulty(v, &miner_id, deadline_index, partition_index, sector_number)); assert_eq!(miner_power(v, &miner_id).raw, BigInt::from(sector_size as i64)); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test_case(false; "v1")] @@ -200,7 +203,7 @@ fn upgrade_and_miss_post_test( assert!(!check_sector_faulty(v, &miner_id, deadline_index, partition_index, sector_number)); assert_eq!(miner_power(v, &miner_id).raw, BigInt::from(sector_size as i64)); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -343,7 +346,7 @@ fn prove_replica_update_multi_dline_test(v: &dyn VM) { assert_eq!(old_sector_commr_p2, new_sector_info_p2.sector_key_cid.unwrap()); assert_eq!(new_sealed_cid2, new_sector_info_p2.sealed_cid); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } // ---- Failure cases ---- @@ -401,7 +404,7 @@ fn immutable_deadline_failure_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -460,7 +463,11 @@ fn unhealthy_sector_failure_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -530,7 +537,7 @@ fn terminated_sector_failure_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -588,7 +595,7 @@ fn bad_batch_size_failure_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -617,7 +624,7 @@ fn nodispute_after_upgrade_test( ExitCode::USR_ILLEGAL_ARGUMENT, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -662,7 +669,7 @@ fn upgrade_bad_post_dispute_test( Some(dispute_params), ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -744,7 +751,7 @@ fn bad_post_upgrade_dispute_test(v: &dyn VM) { Some(dispute_params), ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } // Tests that an active CC sector can be correctly upgraded, and then the sector can be terminated @@ -803,7 +810,7 @@ fn terminate_after_upgrade_test( assert!(network_stats.total_qa_bytes_committed.is_zero()); assert!(network_stats.total_pledge_collateral.is_zero()); - assert_invariants(v); + assert_invariants(v, &Policy::default()); } // Tests that an active CC sector can be correctly upgraded, and then the sector can be extended @@ -871,7 +878,7 @@ fn extend_after_upgrade_test( final_sector_info.expiration - extension_epoch, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -934,7 +941,7 @@ fn wrong_deadline_index_failure_test(v: &dyn VM) { let new_sector_info = sector_info(v, &maddr, sector_number); assert_eq!(old_sector_info, new_sector_info); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -997,7 +1004,7 @@ fn wrong_partition_index_failure_test(v: &dyn VM) { let new_sector_info = sector_info(v, &maddr, sector_number); assert_eq!(old_sector_info, new_sector_info); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -1127,7 +1134,7 @@ fn deal_included_in_multiple_sectors_failure_test(v: &dyn VM) { assert!(new_sector_info_p2.deal_ids.len().is_zero()); assert_ne!(new_sealed_cid2, new_sector_info_p2.sealed_cid); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] diff --git a/test_vm/tests/terminate_test.rs b/test_vm/tests/terminate_test.rs index b565d6c5d..1c46ea77b 100644 --- a/test_vm/tests/terminate_test.rs +++ b/test_vm/tests/terminate_test.rs @@ -352,5 +352,9 @@ fn terminate_sectors_test(v: &dyn VM) { assert!(TokenAmount::from_whole(58) < value_withdrawn); assert!(TokenAmount::from_whole(59) > value_withdrawn); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } diff --git a/test_vm/tests/test_vm_test.rs b/test_vm/tests/test_vm_test.rs index b705eb578..c61c24370 100644 --- a/test_vm/tests/test_vm_test.rs +++ b/test_vm/tests/test_vm_test.rs @@ -1,4 +1,5 @@ use fil_actor_account::State as AccountState; +use fil_actors_runtime::runtime::Policy; use fil_actors_runtime::test_utils::{ make_identity_cid, ACCOUNT_ACTOR_CODE_ID, PAYCH_ACTOR_CODE_ID, }; @@ -47,7 +48,7 @@ fn state_control() { assert_eq!(None, v.get_actor(&addr2)); assert_eq!(v.get_actor(&addr1).unwrap(), a1); - let invariants_check = check_invariants(&v); + let invariants_check = check_invariants(&v, &Policy::default()); assert!(invariants_check.is_err()); assert!(invariants_check.unwrap_err().to_string().contains("AccountState is empty")); } @@ -61,7 +62,7 @@ fn assert_account_actor( ) { let act = v.get_actor(&addr).unwrap(); let st: AccountState = get_state(v, &addr).unwrap(); - assert_eq!(exp_call_seq, act.call_seq_num); + assert_eq!(exp_call_seq, act.call_seq); assert_eq!(*ACCOUNT_ACTOR_CODE_ID, act.code); assert_eq!(exp_bal, act.balance); assert_eq!(exp_pk_addr, st.address); @@ -115,7 +116,7 @@ fn test_sent() { assert_account_actor(3, TokenAmount::from_atto(42u8), addr1, &v, expect_id_addr1); assert_account_actor(2, TokenAmount::zero(), addr2, &v, expect_id_addr2); - assert_invariants(&v) + assert_invariants(&v, &Policy::default()) } #[test] diff --git a/test_vm/tests/verified_claim_test.rs b/test_vm/tests/verified_claim_test.rs index fb56ead1d..b09aa89b0 100644 --- a/test_vm/tests/verified_claim_test.rs +++ b/test_vm/tests/verified_claim_test.rs @@ -362,7 +362,11 @@ fn verified_claim_scenario_test(v: &dyn VM) { assert_eq!(vec![claim_id], ret.considered); assert!(ret.results.all_ok(), "results had failures {}", ret.results); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -456,7 +460,11 @@ fn expired_allocations_test(v: &dyn VM) { // Client has original datacap balance assert_eq!(TokenAmount::from_whole(datacap), datacap_get_balance(v, &verified_client)); - expect_invariants(v, &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()]); + expect_invariants( + v, + &Policy::default(), + &[invariant_failure_patterns::REWARD_STATE_EPOCH_MISMATCH.to_owned()], + ); } #[test] @@ -491,7 +499,7 @@ fn deal_passes_claim_fails_test(v: &dyn VM) { market_add_balance(v, &worker, &miner_id, &TokenAmount::from_whole(64)); // Publish verified deal - let deal_start = v.epoch() + v.policy().maximum_verified_allocation_expiration + 1; + let deal_start = v.epoch() + Policy::default().maximum_verified_allocation_expiration + 1; let sector_start = deal_start; let deal_term_min = 180 * EPOCHS_IN_DAY; let deal_size = (32u64 << 30) / 2; @@ -591,5 +599,5 @@ fn deal_passes_claim_fails_test(v: &dyn VM) { assert_eq!(None, sector_info_a); // run check before last change and confirm that we hit the expected broken state error - assert_invariants(v); + assert_invariants(v, &Policy::default()); } diff --git a/test_vm/tests/verifreg_remove_datacap_test.rs b/test_vm/tests/verifreg_remove_datacap_test.rs index c291801b6..139616e92 100644 --- a/test_vm/tests/verifreg_remove_datacap_test.rs +++ b/test_vm/tests/verifreg_remove_datacap_test.rs @@ -1,3 +1,4 @@ +use fil_actors_runtime::runtime::Policy; use fvm_ipld_blockstore::MemoryBlockstore; use fvm_ipld_encoding::{to_vec, RawBytes}; use fvm_shared::bigint::bigint_ser::BigIntDe; @@ -298,7 +299,7 @@ fn remove_datacap_simple_successful_path_test(v: &dyn VM) { .unwrap(); assert_eq!(2u64, verifier2_proposal_id.id); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } #[test] @@ -360,7 +361,7 @@ fn remove_datacap_fails_on_verifreg_test(v: &dyn VM) { ExitCode::USR_ILLEGAL_ARGUMENT, ); - assert_invariants(v) + assert_invariants(v, &Policy::default()) } fn expect_remove_datacap(