Skip to content

Commit

Permalink
itests green
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Jan 9, 2024
1 parent 6f8be0d commit f92222d
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 45 deletions.
2 changes: 1 addition & 1 deletion actors/miner/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ pub fn expect_sector_event_with_market_call(
rt.expect_send_simple(
STORAGE_MARKET_ACTOR_ADDR,
MarketMethod::GetDealDataCommitmentExported as u64,
IpldBlock::serialize_cbor(&ext::market::GetDealDataCommitmentParams { id: *deal_id })
IpldBlock::serialize_cbor(&ext::market::GetDealDataCommitmentParamsRef { id: *deal_id })
.unwrap(),
TokenAmount::zero(),
IpldBlock::serialize_cbor(&ext::market::GetDealDataCommitmentReturn {
Expand Down
13 changes: 7 additions & 6 deletions integration_tests/src/expects.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use cid::Cid;
use frc46_token::receiver::{FRC46TokenReceived, FRC46_TOKEN_TYPE};
use frc46_token::token::types::BurnParams;
Expand Down Expand Up @@ -56,7 +55,7 @@ impl Expect {
) -> ExpectInvocation {
let events: Vec<EmittedEvent> = deals
.iter()
.map(|deal_id| Expect::build_market_event("deal-activated", &deal_id, client_id, &from))
.map(|deal_id| Expect::build_market_event("deal-activated", deal_id, client_id, &from))
.collect();

let params = IpldBlock::serialize_cbor(&BatchActivateDealsParams {
Expand Down Expand Up @@ -84,11 +83,13 @@ impl Expect {
from: ActorID,
epoch: ChainEpoch,
sectors: Vec<SectorNumber>,
deal_clients: Vec<(DealID, ActorID)>,
deal_clients: Vec<(DealID, ActorID)>,
) -> ExpectInvocation {
let events: Vec<EmittedEvent> = deal_clients
.iter()
.map(|(deal_id,client)| Expect::build_market_event("deal-terminated", &deal_id, &client, &from))
.map(|(deal_id, client)| {
Expect::build_market_event("deal-terminated", deal_id, client, &from)
})
.collect();

let bf = BitField::try_from_bits(sectors).unwrap();
Expand Down Expand Up @@ -233,7 +234,7 @@ impl Expect {
amount: TokenAmount,
operator_data: RawBytes,
burn: bool,
alloc_events: Vec<EmittedEvent>,
claim_events: Vec<EmittedEvent>,
) -> ExpectInvocation {
let payload = IpldBlock::serialize_cbor(&FRC46TokenReceived {
from,
Expand Down Expand Up @@ -265,7 +266,7 @@ impl Expect {
.unwrap(),
),
subinvocs: Some(burn_invocs),
events: alloc_events,
events: claim_events,
..Default::default()
}]),
..Default::default()
Expand Down
40 changes: 28 additions & 12 deletions integration_tests/src/tests/extend_sectors_test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
use cid::Cid;
use fvm_ipld_bitfield::BitField;
use fvm_shared::address::Address;
use fvm_shared::bigint::Zero;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::econ::TokenAmount;
use fvm_shared::piece::{PaddedPieceSize, PieceInfo};
use fvm_shared::sector::{RegisteredSealProof, SectorNumber, StoragePower};
use export_macro::vm_test;
use fil_actor_miner::{
max_prove_commit_duration, power_for_sector, ExpirationExtension, ExpirationExtension2,
Expand All @@ -16,13 +9,30 @@ use fil_actor_miner::{
use fil_actor_verifreg::Method as VerifregMethod;
use fil_actors_runtime::runtime::Policy;
use fil_actors_runtime::test_utils::{make_piece_cid, make_sealed_cid};
use fil_actors_runtime::{DealWeight, EPOCHS_IN_DAY, STORAGE_MARKET_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR};
use fil_actors_runtime::{
DealWeight, EPOCHS_IN_DAY, STORAGE_MARKET_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR,
};
use fvm_ipld_bitfield::BitField;
use fvm_shared::address::Address;
use fvm_shared::bigint::Zero;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::econ::TokenAmount;
use fvm_shared::piece::{PaddedPieceSize, PieceInfo};
use fvm_shared::sector::{RegisteredSealProof, SectorNumber, StoragePower};
use vm_api::trace::ExpectInvocation;
use vm_api::util::{apply_ok, get_state, mutate_state, DynBlockstore};
use vm_api::VM;

use crate::expects::Expect;
use crate::util::{advance_by_deadline_to_epoch, advance_by_deadline_to_epoch_while_proving, advance_by_deadline_to_index, advance_to_proving_deadline, bf_all, create_accounts, create_miner, cron_tick, expect_invariants, invariant_failure_patterns, market_add_balance, market_pending_deal_allocations, market_publish_deal, miner_precommit_one_sector_v2, miner_prove_sector, precommit_meta_data_from_deals, sector_deadline, submit_windowed_post, verifreg_add_client, verifreg_add_verifier, PrecommitMetadata, override_compute_unsealed_sector_cid};
use crate::util::{
advance_by_deadline_to_epoch, advance_by_deadline_to_epoch_while_proving,
advance_by_deadline_to_index, advance_to_proving_deadline, bf_all, create_accounts,
create_miner, cron_tick, expect_invariants, invariant_failure_patterns, market_add_balance,
market_pending_deal_allocations, market_publish_deal, miner_precommit_one_sector_v2,
miner_prove_sector, override_compute_unsealed_sector_cid, precommit_meta_data_from_deals,
sector_deadline, submit_windowed_post, verifreg_add_client, verifreg_add_verifier,
PrecommitMetadata,
};

#[allow(clippy::too_many_arguments)]
pub fn extend(
Expand Down Expand Up @@ -523,7 +533,7 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) {
let policy = Policy::default();
let deal_label = "deal1".to_string();
let piece_cid = make_piece_cid(deal_label.as_bytes());
let piece_size = PaddedPieceSize(32u64 << 30);
let piece_size = PaddedPieceSize(32u64 << 30);

// create miner
let miner_addr = create_miner(
Expand Down Expand Up @@ -613,7 +623,7 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) {
&verified_client,
&miner_addr,
deal_label,
piece_size,
piece_size,
true,
deal_start,
340 * EPOCHS_IN_DAY,
Expand Down Expand Up @@ -694,7 +704,13 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) {
PowerPair { raw: StoragePower::zero(), qa: 9 * old_power.qa },
),
]),
events: vec![Expect::build_sector_activation_event("sector-updated", &miner_id, &sector_number, &unsealed_cid, &pieces)],
events: vec![Expect::build_sector_activation_event(
"sector-updated",
&miner_id,
&sector_number,
&unsealed_cid,
&pieces,
)],
..Default::default()
}
.matches(v.take_invocations().last().unwrap());
Expand Down
8 changes: 6 additions & 2 deletions integration_tests/src/tests/prove_commit2_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use fvm_shared::piece::{PaddedPieceSize, PieceInfo};
use fvm_shared::sector::{
RegisteredAggregateProof, RegisteredSealProof, SectorNumber, StoragePower,
};
use integer_encoding::VarInt;
use num_traits::Zero;

use fil_actor_market::Method as MarketMethod;
Expand All @@ -36,7 +35,12 @@ use vm_api::VM;

use crate::deals::{DealBatcher, DealOptions};
use crate::expects::Expect;
use crate::util::{advance_by_deadline_to_epoch, create_accounts, create_miner, datacap_create_allocations, market_add_balance, market_list_deals, market_list_sectors_deals, precommit_sectors_v2, sector_info, verifreg_add_client, verifreg_add_verifier, verifreg_list_claims, PrecommitMetadata, override_compute_unsealed_sector_cid};
use crate::util::{
advance_by_deadline_to_epoch, create_accounts, create_miner, datacap_create_allocations,
market_add_balance, market_list_deals, market_list_sectors_deals,
override_compute_unsealed_sector_cid, precommit_sectors_v2, sector_info, verifreg_add_client,
verifreg_add_verifier, verifreg_list_claims, PrecommitMetadata,
};

#[vm_test]
pub fn prove_commit_sectors2_test(v: &dyn VM) {
Expand Down
40 changes: 35 additions & 5 deletions integration_tests/src/tests/replica_update2_test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use cid::Cid;
use export_macro::vm_test;
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_ipld_encoding::RawBytes;
use fvm_shared::bigint::BigInt;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::deal::DealID;
use fvm_shared::econ::TokenAmount;
use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::piece::{PaddedPieceSize, PieceInfo};
use fvm_shared::sector::{
RegisteredAggregateProof, RegisteredSealProof, SectorNumber, StoragePower,
};
Expand All @@ -29,7 +30,7 @@ use fil_actors_runtime::test_utils::{make_piece_cid, make_sealed_cid};
use fil_actors_runtime::{
EPOCHS_IN_DAY, EPOCHS_IN_YEAR, STORAGE_MARKET_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR,
};
use vm_api::trace::ExpectInvocation;
use vm_api::trace::{EmittedEvent, ExpectInvocation};
use vm_api::util::apply_ok;
use vm_api::VM;

Expand All @@ -38,13 +39,15 @@ use crate::expects::Expect;
use crate::util::{
advance_by_deadline_to_epoch, advance_by_deadline_to_index, advance_to_proving_deadline,
create_accounts, create_miner, datacap_create_allocations, market_add_balance,
market_list_deals, market_list_sectors_deals, precommit_sectors_v2, sector_info,
submit_windowed_post, verifreg_add_client, verifreg_add_verifier, verifreg_list_claims,
PrecommitMetadata,
market_list_deals, market_list_sectors_deals, override_compute_unsealed_sector_cid,
precommit_sectors_v2, sector_info, submit_windowed_post, verifreg_add_client,
verifreg_add_verifier, verifreg_list_claims, PrecommitMetadata,
};

#[vm_test]
pub fn prove_replica_update2_test(v: &dyn VM) {
override_compute_unsealed_sector_cid(v);

let policy = Policy::default();
let addrs = create_accounts(v, 3, &TokenAmount::from_whole(10_000));
let seal_proof = RegisteredSealProof::StackedDRG32GiBV1P1;
Expand Down Expand Up @@ -276,6 +279,27 @@ pub fn prove_replica_update2_test(v: &dyn VM) {
.map(|p| p.size.0 * 9)
.sum::<u64>(),
);

let events: Vec<EmittedEvent> = manifests
.iter()
.map(|m| {
let pieces: Vec<(Cid, PaddedPieceSize)> =
m.pieces.iter().map(|p| (p.cid, p.size)).collect();

let pis: Vec<PieceInfo> =
m.pieces.iter().map(|p| PieceInfo { cid: p.cid, size: p.size }).collect();
let unsealed_cid =
v.primitives().compute_unsealed_sector_cid(seal_proof, &pis).unwrap();
Expect::build_sector_activation_event(
"sector-updated",
&miner_id,
&m.sector,
&unsealed_cid,
&pieces,
)
})
.collect();

ExpectInvocation {
from: worker_id,
to: maddr,
Expand Down Expand Up @@ -326,6 +350,11 @@ pub fn prove_replica_update2_test(v: &dyn VM) {
})
.unwrap(),
),
events: vec![
Expect::build_verifreg_event("claim", &alloc_ids_s2[0], &client_id, &miner_id),
Expect::build_verifreg_event("claim", &alloc_ids_s2[1], &client_id, &miner_id),
Expect::build_verifreg_event("claim", &alloc_ids_s4[0], &client_id, &miner_id),
],
..Default::default()
},
Expect::reward_this_epoch(miner_id),
Expand Down Expand Up @@ -359,6 +388,7 @@ pub fn prove_replica_update2_test(v: &dyn VM) {
..Default::default()
},
]),
events,
..Default::default()
}
.matches(v.take_invocations().last().unwrap());
Expand Down
31 changes: 25 additions & 6 deletions integration_tests/src/tests/replica_update_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ use vm_api::VM;

use crate::expects::Expect;

use crate::util::{advance_by_deadline_to_epoch, advance_by_deadline_to_index, advance_to_proving_deadline, assert_invariants, bf_all, check_sector_active, check_sector_faulty, create_accounts, create_miner, deadline_state, declare_recovery, expect_invariants, get_deal_weights, get_network_stats, invariant_failure_patterns, make_bitfield, market_publish_deal, miner_balance, miner_power, override_compute_unsealed_sector_cid, precommit_sectors_v2, prove_commit_sectors, sector_info, submit_invalid_post, submit_windowed_post, verifreg_add_client, verifreg_add_verifier};
use crate::util::{
advance_by_deadline_to_epoch, advance_by_deadline_to_index, advance_to_proving_deadline,
assert_invariants, bf_all, check_sector_active, check_sector_faulty, create_accounts,
create_miner, deadline_state, declare_recovery, expect_invariants, get_deal_weights,
get_network_stats, invariant_failure_patterns, make_bitfield, market_publish_deal,
miner_balance, miner_power, override_compute_unsealed_sector_cid, precommit_sectors_v2,
prove_commit_sectors, sector_info, submit_invalid_post, submit_windowed_post,
verifreg_add_client, verifreg_add_verifier,
};

#[vm_test]
pub fn replica_update_full_path_success_test(v: &dyn VM) {
Expand Down Expand Up @@ -1035,12 +1043,17 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) {
assert_eq!(vec![100], bf_all(updated_sectors));

let claim_id = 1_u64;
let claim_event =
Expect::build_verifreg_event("claim", &claim_id, &client.id().unwrap(), &maddr.id().unwrap());
let claim_event = Expect::build_verifreg_event(
"claim",
&claim_id,
&client.id().unwrap(),
&maddr.id().unwrap(),
);
let old_power = power_for_sector(seal_proof.sector_size().unwrap(), &old_sector_info);

let pieces: Vec<(Cid, PaddedPieceSize)> = vec![(proposal.piece_cid, proposal.piece_size)];
let pis: Vec<PieceInfo> = vec![PieceInfo { cid:proposal.piece_cid, size: proposal.piece_size}];
let pis: Vec<PieceInfo> =
vec![PieceInfo { cid: proposal.piece_cid, size: proposal.piece_size }];
let unsealed_cid = v.primitives().compute_unsealed_sector_cid(seal_proof, &pis).unwrap();

// check for the expected subcalls
Expand All @@ -1062,7 +1075,7 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) {
from: miner_id,
to: VERIFIED_REGISTRY_ACTOR_ADDR,
method: VerifregMethod::ClaimAllocations as u64,
events:vec![claim_event],
events: vec![claim_event],
..Default::default()
},
ExpectInvocation {
Expand All @@ -1080,7 +1093,13 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) {
PowerPair { raw: StoragePower::zero(), qa: 9 * old_power.qa },
),
]),
events: vec![Expect::build_sector_activation_event("sector-updated", &miner_id, &sector_number, &unsealed_cid, &pieces)],
events: vec![Expect::build_sector_activation_event(
"sector-updated",
&miner_id,
&sector_number,
&unsealed_cid,
&pieces,
)],
..Default::default()
}
.matches(v.take_invocations().last().unwrap());
Expand Down
19 changes: 13 additions & 6 deletions integration_tests/src/tests/terminate_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use export_macro::vm_test;
use fil_actor_cron::Method as CronMethod;
use fil_actor_market::{
Expand All @@ -17,14 +16,14 @@ use fil_actors_runtime::{
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 fvm_shared::ActorID;
use fvm_shared::deal::DealID;
use vm_api::trace::ExpectInvocation;
use vm_api::util::{apply_ok, get_state, DynBlockstore};
use vm_api::VM;
Expand Down Expand Up @@ -247,8 +246,11 @@ pub fn terminate_sectors_test(v: &dyn VM) {
let epoch = v.epoch();

let expect_event = Expect::build_miner_event("sector-terminated", miner_id, sector_number);
let mut deal_clients:Vec<(DealID, ActorID)> = vec![(deal_ids[0], verified_client_id), (deal_ids[1], verified_client_id),
(deal_ids[2], unverified_client.id().unwrap())];
let deal_clients: Vec<(DealID, ActorID)> = vec![
(deal_ids[0], verified_client_id),
(deal_ids[1], verified_client_id),
(deal_ids[2], unverified_client.id().unwrap()),
];

// Terminate Sector
apply_ok(
Expand All @@ -274,7 +276,12 @@ pub fn terminate_sectors_test(v: &dyn VM) {
Expect::power_current_total(miner_id),
Expect::burn(miner_id, None),
Expect::power_update_pledge(miner_id, None),
Expect::market_sectors_terminate(miner_id, epoch, [sector_number].to_vec(), deal_clients),
Expect::market_sectors_terminate(
miner_id,
epoch,
[sector_number].to_vec(),
deal_clients,
),
Expect::power_update_claim(miner_id, sector_power.neg()),
]),
events: vec![expect_event],
Expand Down
10 changes: 9 additions & 1 deletion integration_tests/src/tests/verified_claim_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,15 @@ pub fn verified_claim_scenario_test(v: &dyn VM) {
let new_max_term = new_claim_expiry_epoch - claim.term_start;
assert!(new_max_term > original_max_term);

datacap_extend_claim(v, &verified_client, &miner_id, claim_id, deal_size, new_max_term);
datacap_extend_claim(
v,
&verified_client2,
&miner_id,
claim_id,
deal_size,
new_max_term,
&verified_client.id().unwrap(),
);

// The miner extends the sector into the second year.
let extended_expiration_2 = extended_expiration_1 + 60 * EPOCHS_IN_DAY;
Expand Down
Loading

0 comments on commit f92222d

Please sign in to comment.