Skip to content

Commit

Permalink
Test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Sep 3, 2023
1 parent db488bc commit a090386
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 43 deletions.
4 changes: 2 additions & 2 deletions integration_tests/src/tests/extend_sectors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) {
&worker,
&miner_addr,
&TokenAmount::zero(),
MinerMethod::ProveReplicaUpdates2 as u64,
MinerMethod::ProveReplicaUpdates as u64,
Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }),
)
.deserialize()
Expand All @@ -640,7 +640,7 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) {
ExpectInvocation {
from: worker_id,
to: miner_addr,
method: MinerMethod::ProveReplicaUpdates2 as u64,
method: MinerMethod::ProveReplicaUpdates as u64,
subinvocs: Some(vec![
Expect::market_activate_deals(
miner_id,
Expand Down
43 changes: 12 additions & 31 deletions integration_tests/src/tests/replica_update_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ use crate::util::{
};

#[allow(clippy::too_many_arguments)]
pub fn replica_update_full_path_success_test(v: &dyn VM, v2: bool) {
pub fn replica_update_full_path_success_test(v: &dyn VM) {
let policy = Policy::default();
let (sector_info, worker, miner_id, deadline_index, partition_index, sector_size) =
create_miner_and_upgrade_sector(v, v2);
create_miner_and_upgrade_sector(v);

let sector_number = sector_info.sector_number;

Expand Down Expand Up @@ -94,9 +94,9 @@ pub fn replica_update_full_path_success_test(v: &dyn VM, v2: bool) {
}

#[allow(clippy::too_many_arguments)]
pub fn upgrade_and_miss_post_test(v: &dyn VM, v2: bool) {
pub fn upgrade_and_miss_post_test(v: &dyn VM) {
let (sector_info, worker, miner_id, deadline_index, partition_index, sector_size) =
create_miner_and_upgrade_sector(v, v2);
create_miner_and_upgrade_sector(v);
let sector_number = sector_info.sector_number;
let policy = Policy::default();

Expand Down Expand Up @@ -503,7 +503,7 @@ pub fn bad_batch_size_failure_test(v: &dyn VM) {
}

pub fn nodispute_after_upgrade_test(v: &dyn VM) {
let (_, worker, miner_id, deadline_index, _, _) = create_miner_and_upgrade_sector(v, false);
let (_, worker, miner_id, deadline_index, _, _) = create_miner_and_upgrade_sector(v);

let dispute_params = DisputeWindowedPoStParams { deadline: deadline_index, post_index: 0 };
apply_code(
Expand All @@ -521,7 +521,7 @@ pub fn nodispute_after_upgrade_test(v: &dyn VM) {

pub fn upgrade_bad_post_dispute_test(v: &dyn VM) {
let (sector_info, worker, miner_id, deadline_index, partition_index, _) =
create_miner_and_upgrade_sector(v, false);
create_miner_and_upgrade_sector(v);
let policy = Policy::default();
let sector_number = sector_info.sector_number;

Expand Down Expand Up @@ -621,7 +621,7 @@ pub fn bad_post_upgrade_dispute_test(v: &dyn VM) {
/// Tests that an active CC sector can be correctly upgraded, and then the sector can be terminated
pub fn terminate_after_upgrade_test(v: &dyn VM) {
let (sector_info, worker, miner_id, deadline_index, partition_index, _) =
create_miner_and_upgrade_sector(v, false);
create_miner_and_upgrade_sector(v);
let sector_number = sector_info.sector_number;

let terminate_params = TerminateSectorsParams {
Expand Down Expand Up @@ -662,7 +662,7 @@ pub fn terminate_after_upgrade_test(v: &dyn VM) {
pub fn extend_after_upgrade_test(v: &dyn VM) {
let policy = Policy::default();
let (sector_info, worker, miner_id, deadline_index, partition_index, _) =
create_miner_and_upgrade_sector(v, false);
create_miner_and_upgrade_sector(v);

let sector_number = sector_info.sector_number;
let mut legacy_sector = sector_info;
Expand Down Expand Up @@ -996,7 +996,7 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) {
&worker,
&robust,
&TokenAmount::zero(),
MinerMethod::ProveReplicaUpdates2 as u64,
MinerMethod::ProveReplicaUpdates as u64,
Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }),
)
.deserialize()
Expand All @@ -1008,7 +1008,7 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) {
ExpectInvocation {
from: worker_id,
to: maddr,
method: MinerMethod::ProveReplicaUpdates2 as u64,
method: MinerMethod::ProveReplicaUpdates as u64,
subinvocs: Some(vec![
Expect::market_activate_deals(
miner_id,
Expand Down Expand Up @@ -1097,7 +1097,7 @@ pub fn replica_update_verified_deal_max_term_violated_test(v: &dyn VM) {
&worker,
&robust,
&TokenAmount::zero(),
MinerMethod::ProveReplicaUpdates2 as u64,
MinerMethod::ProveReplicaUpdates as u64,
Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }),
ExitCode::USR_ILLEGAL_ARGUMENT,
);
Expand Down Expand Up @@ -1256,7 +1256,6 @@ fn create_deals_frac(

pub fn create_miner_and_upgrade_sector(
v: &dyn VM,
v2: bool,
) -> (SectorOnChainInfo, Address, Address, u64, u64, SectorSize) {
let addrs = create_accounts(v, 1, &TokenAmount::from_whole(100_000));
let (worker, owner) = (addrs[0], addrs[0]);
Expand All @@ -1281,7 +1280,7 @@ pub fn create_miner_and_upgrade_sector(

// replica update
let new_sealed_cid = make_sealed_cid(b"replica1");
let updated_sectors: BitField = if !v2 {
let updated_sectors: BitField = {
let replica_update = ReplicaUpdate {
sector_number,
deadline: d_idx,
Expand All @@ -1299,24 +1298,6 @@ pub fn create_miner_and_upgrade_sector(
MinerMethod::ProveReplicaUpdates as u64,
Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }),
)
} else {
let replica_update = ReplicaUpdate {
sector_number,
deadline: d_idx,
partition: p_idx,
new_sealed_cid,
deals: deal_ids.clone(),
update_proof_type: fvm_shared::sector::RegisteredUpdateProof::StackedDRG32GiBV1,
replica_proof: vec![].into(),
};
apply_ok(
v,
&worker,
&robust,
&TokenAmount::zero(),
MinerMethod::ProveReplicaUpdates2 as u64,
Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }),
)
}
.deserialize()
.unwrap();
Expand Down
17 changes: 7 additions & 10 deletions test_vm/tests/replica_update_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,27 @@ use fil_actors_integration_tests::util::assert_invariants;

// ---- Success cases ----
// Tests that an active CC sector can be correctly upgraded, and the expected state changes occur
#[test_case(false; "v1")]
#[test_case(true; "v2")]
fn replica_update_simple_path_success(v2: bool) {
#[test]
fn replica_update_simple_path_success() {
let store = &MemoryBlockstore::new();
let v = TestVM::<MemoryBlockstore>::new_with_singletons(store);
create_miner_and_upgrade_sector(&v, v2);
create_miner_and_upgrade_sector(&v);
assert_invariants(&v, &Policy::default());
}

// Tests a successful upgrade, followed by the sector going faulty and recovering
#[test_case(false; "v1")]
#[test_case(true; "v2")]
#[test]
fn replica_update_full_path_success(v2: bool) {
let store = &MemoryBlockstore::new();
let v = TestVM::<MemoryBlockstore>::new_with_singletons(store);
replica_update_full_path_success_test(&v, v2);
replica_update_full_path_success_test(&v);
}

#[test_case(false; "v1")]
#[test_case(true; "v2")]
#[test]
fn upgrade_and_miss_post(v2: bool) {
let store = &MemoryBlockstore::new();
let v = TestVM::<MemoryBlockstore>::new_with_singletons(store);
upgrade_and_miss_post_test(&v, v2);
upgrade_and_miss_post_test(&v);
}

#[test]
Expand Down

0 comments on commit a090386

Please sign in to comment.