diff --git a/actors/market/tests/on_miner_sectors_terminate.rs b/actors/market/tests/on_miner_sectors_terminate.rs index 2f2cf4375..f510f9b2e 100644 --- a/actors/market/tests/on_miner_sectors_terminate.rs +++ b/actors/market/tests/on_miner_sectors_terminate.rs @@ -270,6 +270,7 @@ fn terminate_valid_deals_along_with_expired_and_cleaned_up_deal() { check_state(&rt); } +// Converted from: https://github.com/filecoin-project/specs-actors/blob/d56b240af24517443ce1f8abfbdab7cb22d331f1/actors/builtin/market/market_test.go#L1415 #[test] fn do_not_terminate_deal_if_end_epoch_is_equal_to_or_less_than_current_epoch() { let start_epoch = 10; diff --git a/integration_tests/src/tests/batch_onboarding_deals_test.rs b/integration_tests/src/tests/batch_onboarding_deals_test.rs index d94d927a1..79f986125 100644 --- a/integration_tests/src/tests/batch_onboarding_deals_test.rs +++ b/integration_tests/src/tests/batch_onboarding_deals_test.rs @@ -144,7 +144,7 @@ pub fn batch_onboarding_deals_test(v: &dyn VM) { // Associate deals with sectors. let sector_precommit_data = deals .into_iter() - .map(|(id, _)| precommit_meta_data_from_deals(v, vec![id], SEAL_PROOF)) + .map(|(id, _)| precommit_meta_data_from_deals(v, &[id], SEAL_PROOF)) .collect(); // Pre-commit as single batch. diff --git a/integration_tests/src/tests/extend_sectors_test.rs b/integration_tests/src/tests/extend_sectors_test.rs index 82a0f067a..92871a9b0 100644 --- a/integration_tests/src/tests/extend_sectors_test.rs +++ b/integration_tests/src/tests/extend_sectors_test.rs @@ -165,7 +165,7 @@ pub fn extend_legacy_sector_with_deals_test(v: &dyn VM, do_extend2: bool) { &miner_id, seal_proof, sector_number, - precommit_meta_data_from_deals(v, deals, seal_proof), + precommit_meta_data_from_deals(v, &deals, seal_proof), true, deal_start + 180 * EPOCHS_IN_DAY, ); @@ -393,7 +393,7 @@ pub fn commit_sector_with_max_duration_deal_test(v: &dyn VM) { &miner_id, seal_proof, sector_number, - precommit_meta_data_from_deals(v, deals, seal_proof), + precommit_meta_data_from_deals(v, &deals, seal_proof), true, deal_start + deal_lifetime, ); diff --git a/integration_tests/src/tests/terminate_test.rs b/integration_tests/src/tests/terminate_test.rs index 638b598a2..e60449d73 100644 --- a/integration_tests/src/tests/terminate_test.rs +++ b/integration_tests/src/tests/terminate_test.rs @@ -1,3 +1,12 @@ +use std::ops::Neg; + +use fvm_shared::bigint::Zero; +use fvm_shared::econ::TokenAmount; +use fvm_shared::error::ExitCode; +use fvm_shared::piece::PaddedPieceSize; +use fvm_shared::sector::{RegisteredSealProof, StoragePower}; +use num_traits::cast::FromPrimitive; + use export_macro::vm_test; use fil_actor_cron::Method as CronMethod; use fil_actor_market::{ @@ -15,15 +24,8 @@ use fil_actors_runtime::{ CRON_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ID, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, }; -use fvm_shared::bigint::Zero; use fvm_shared::deal::DealID; -use fvm_shared::econ::TokenAmount; -use fvm_shared::error::ExitCode; -use fvm_shared::piece::PaddedPieceSize; -use fvm_shared::sector::{RegisteredSealProof, StoragePower}; use fvm_shared::ActorID; -use num_traits::cast::FromPrimitive; -use std::ops::Neg; use vm_api::trace::ExpectInvocation; use vm_api::util::{apply_ok, get_state, DynBlockstore}; use vm_api::VM; @@ -175,7 +177,7 @@ pub fn terminate_sectors_test(v: &dyn VM) { &miner_robust_addr, seal_proof, sector_number, - precommit_meta_data_from_deals(v, deal_ids.clone(), seal_proof), + precommit_meta_data_from_deals(v, &deal_ids, seal_proof), true, v.epoch() + 220 * EPOCHS_IN_DAY, ); diff --git a/integration_tests/src/tests/verified_claim_test.rs b/integration_tests/src/tests/verified_claim_test.rs index 7c82568a1..684618e2b 100644 --- a/integration_tests/src/tests/verified_claim_test.rs +++ b/integration_tests/src/tests/verified_claim_test.rs @@ -7,7 +7,7 @@ use fvm_shared::piece::PaddedPieceSize; use fvm_shared::sector::{RegisteredSealProof, SectorNumber, StoragePower}; use fil_actor_datacap::State as DatacapState; -use fil_actor_market::{DealArray, DealMetaArray}; +use fil_actor_market::{DealArray, DealMetaArray, DealSettlementSummary}; use fil_actor_market::{ PendingDealAllocationsMap, State as MarketState, PENDING_ALLOCATIONS_CONFIG, }; @@ -36,9 +36,9 @@ use crate::util::{ create_miner, cron_tick, datacap_extend_claim, datacap_get_balance, expect_invariants, invariant_failure_patterns, market_add_balance, market_pending_deal_allocations, market_publish_deal, miner_extend_sector_expiration2, miner_precommit_one_sector_v2, - miner_prove_sector, precommit_meta_data_from_deals, sector_deadline, submit_windowed_post, - verifreg_add_client, verifreg_add_verifier, verifreg_extend_claim_terms, - verifreg_remove_expired_allocations, + miner_prove_sector, precommit_meta_data_from_deals, provider_settle_deal_payments, + sector_deadline, submit_windowed_post, verifreg_add_client, verifreg_add_verifier, + verifreg_extend_claim_terms, verifreg_remove_expired_allocations, }; /// Tests a scenario involving a verified deal from the built-in market, with associated @@ -102,7 +102,7 @@ pub fn verified_claim_scenario_test(v: &dyn VM) { &miner_id, seal_proof, sector_number, - precommit_meta_data_from_deals(v, deals, seal_proof), + precommit_meta_data_from_deals(v, &deals, seal_proof), true, deal_start + sector_term, ); @@ -362,6 +362,17 @@ pub 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); + let market_state: MarketState = get_state(v, &STORAGE_MARKET_ACTOR_ADDR).unwrap(); + let store = DynBlockstore::wrap(v.blockstore()); + let proposals = DealArray::load(&market_state.proposals, &store).unwrap(); + let proposal = proposals.get(deals[0]).unwrap().unwrap(); + // provider must process the deals to receive payment and cleanup state + let ret = provider_settle_deal_payments(v, &miner_id, &deals); + assert_eq!( + ret.settlements.get(0).unwrap(), + &DealSettlementSummary { payment: proposal.total_storage_fee(), completed: true } + ); + expect_invariants( v, &Policy::default(), @@ -551,7 +562,7 @@ pub fn deal_passes_claim_fails_test(v: &dyn VM) { &miner_id, seal_proof, sector_number_a, - precommit_meta_data_from_deals(v, vec![deal], seal_proof), + precommit_meta_data_from_deals(v, &[deal], seal_proof), true, sector_start + sector_term, ); @@ -562,7 +573,7 @@ pub fn deal_passes_claim_fails_test(v: &dyn VM) { &miner_id, seal_proof, sector_number_b, - precommit_meta_data_from_deals(v, vec![bad_deal], seal_proof), + precommit_meta_data_from_deals(v, &[bad_deal], seal_proof), false, sector_start + sector_term, ); diff --git a/integration_tests/src/util/mod.rs b/integration_tests/src/util/mod.rs index 46d540d64..30c80711c 100644 --- a/integration_tests/src/util/mod.rs +++ b/integration_tests/src/util/mod.rs @@ -1,12 +1,22 @@ use cid::multihash::{Code, MultihashDigest}; use cid::Cid; use fil_actor_market::{load_provider_sector_deals, DealProposal, DealState, State as MarketState}; +use fil_actor_miner::ext::verifreg::AllocationID; +use fil_actor_miner::{ + new_deadline_info_from_offset_and_epoch, CompactCommD, Deadline, DeadlineInfo, + GetBeneficiaryReturn, Method as MinerMethod, MinerInfo, PowerPair, SectorOnChainInfo, + State as MinerState, +}; use fil_actor_power::State as PowerState; use fil_actor_reward::State as RewardState; +use fil_actor_verifreg::{Claim, ClaimID, State as VerifregState}; +use fil_actors_runtime::cbor::serialize; +use fil_actors_runtime::test_utils::make_piece_cid; use fil_actors_runtime::{ parse_uint_key, runtime::Policy, MessageAccumulator, REWARD_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, }; +use fil_builtin_actors_state::check::check_state_invariants; use fvm_ipld_bitfield::BitField; use fvm_ipld_encoding::{CborStore, RawBytes, DAG_CBOR}; use fvm_shared::address::Address; @@ -19,17 +29,6 @@ use integer_encoding::VarInt; use num_traits::Zero; use regex::Regex; use std::collections::HashMap; - -use fil_actor_miner::ext::verifreg::AllocationID; -use fil_actor_miner::{ - new_deadline_info_from_offset_and_epoch, CompactCommD, Deadline, DeadlineInfo, - GetBeneficiaryReturn, Method as MinerMethod, MinerInfo, PowerPair, SectorOnChainInfo, - State as MinerState, -}; -use fil_actor_verifreg::{Claim, ClaimID, State as VerifregState}; -use fil_actors_runtime::cbor::serialize; -use fil_actors_runtime::test_utils::make_piece_cid; -use fil_builtin_actors_state::check::check_state_invariants; use vm_api::{ util::{apply_ok, get_state, pk_addrs_from, DynBlockstore}, VM, diff --git a/integration_tests/src/util/workflows.rs b/integration_tests/src/util/workflows.rs index d796a1885..beaffbc21 100644 --- a/integration_tests/src/util/workflows.rs +++ b/integration_tests/src/util/workflows.rs @@ -349,21 +349,20 @@ pub fn precommit_sectors_v2( pub fn precommit_meta_data_from_deals( v: &dyn VM, - deal_ids: Vec, + deal_ids: &[u64], seal_proof: RegisteredSealProof, ) -> PrecommitMetadata { let state: MarketState = get_state(v, &STORAGE_MARKET_ACTOR_ADDR).unwrap(); let pieces: Vec = deal_ids - .clone() - .into_iter() - .map(|id: u64| { - let deal = state.get_proposal(&DynBlockstore::wrap(v.blockstore()), id).unwrap(); + .iter() + .map(|id: &u64| { + let deal = state.get_proposal(&DynBlockstore::wrap(v.blockstore()), *id).unwrap(); PieceInfo { size: deal.piece_size, cid: deal.piece_cid } }) .collect(); PrecommitMetadata { - deals: deal_ids, + deals: deal_ids.to_vec(), commd: CompactCommD::of( v.primitives().compute_unsealed_sector_cid(seal_proof, &pieces).unwrap(), ),