Skip to content

Commit

Permalink
remove unneeded-cron tests (active deals not processed in cron anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexytsu committed Aug 25, 2023
1 parent f9cca83 commit 7def77a
Showing 1 changed file with 0 additions and 77 deletions.
77 changes: 0 additions & 77 deletions actors/market/tests/random_cron_epoch_during_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use fil_actors_runtime::network::EPOCHS_IN_DAY;
use fil_actors_runtime::runtime::Policy;
use fil_actors_runtime::BURNT_FUNDS_ACTOR_ADDR;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::error::ExitCode;
Expand All @@ -16,82 +15,6 @@ const START_EPOCH: ChainEpoch = 50;
const END_EPOCH: ChainEpoch = START_EPOCH + 200 * EPOCHS_IN_DAY;
const SECTOR_EXPIRY: ChainEpoch = END_EPOCH + 1;

#[test]
fn cron_processing_happens_at_processing_epoch_not_start_epoch() {
let rt = setup();

let deal_id = generate_and_publish_deal(
&rt,
CLIENT_ADDR,
&MinerAddresses::default(),
START_EPOCH,
END_EPOCH,
);
let deal_proposal = get_deal_proposal(&rt, deal_id);

// activate the deal
rt.set_epoch(START_EPOCH - 1);
activate_deals(&rt, SECTOR_EXPIRY, PROVIDER_ADDR, deal_proposal.start_epoch - 1, &[deal_id]);

// cron tick at deal start epoch does not do anything
rt.set_epoch(START_EPOCH);
cron_tick_no_change(&rt, CLIENT_ADDR, PROVIDER_ADDR);

// first cron tick at process epoch will make payment and schedule the deal for next epoch
let deal_epoch = process_epoch(START_EPOCH, deal_id);
rt.set_epoch(deal_epoch);
let (pay, _) =
cron_tick_and_assert_balances(&rt, CLIENT_ADDR, PROVIDER_ADDR, deal_epoch, deal_id);
let duration = deal_epoch - START_EPOCH;
assert_eq!(duration * &deal_proposal.storage_price_per_epoch, pay);

// payment at next epoch
let new_epoch = deal_epoch + Policy::default().deal_updates_interval;
rt.set_epoch(new_epoch);
let (pay, _) =
cron_tick_and_assert_balances(&rt, CLIENT_ADDR, PROVIDER_ADDR, new_epoch, deal_id);
let duration = new_epoch - deal_epoch;
assert_eq!(duration * &deal_proposal.storage_price_per_epoch, pay);

check_state(&rt);
}

#[test]
fn deals_are_scheduled_for_expiry_later_than_the_end_epoch() {
let rt = setup();
let deal_id = generate_and_publish_deal(
&rt,
CLIENT_ADDR,
&MinerAddresses::default(),
START_EPOCH,
END_EPOCH,
);
let deal_proposal = get_deal_proposal(&rt, deal_id);

rt.set_epoch(START_EPOCH - 1);
activate_deals(&rt, SECTOR_EXPIRY, PROVIDER_ADDR, deal_proposal.start_epoch - 1, &[deal_id]);

// a cron tick at end epoch -1 schedules the deal for later than end epoch
let curr = END_EPOCH - 1;
rt.set_epoch(curr);
let duration = curr - START_EPOCH;
let (pay, _) = cron_tick_and_assert_balances(&rt, CLIENT_ADDR, PROVIDER_ADDR, curr, deal_id);
assert_eq!(duration * &deal_proposal.storage_price_per_epoch, pay);

// cron tick at end epoch does NOT expire the deal
rt.set_epoch(END_EPOCH);
cron_tick_no_change(&rt, CLIENT_ADDR, PROVIDER_ADDR);
let _found = get_deal_proposal(&rt, deal_id);

// cron tick at nextEpoch expires the deal -> payment is ONLY for one epoch
let curr = curr + Policy::default().deal_updates_interval;
rt.set_epoch(curr);
let (pay, _) = cron_tick_and_assert_balances(&rt, CLIENT_ADDR, PROVIDER_ADDR, curr, deal_id);
assert_eq!(&deal_proposal.storage_price_per_epoch, &pay);
assert_deal_deleted(&rt, deal_id, deal_proposal);
check_state(&rt);
}

#[test]
fn deal_is_processed_after_its_end_epoch_should_expire_correctly() {
let rt = setup();
Expand Down

0 comments on commit 7def77a

Please sign in to comment.