-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use fil_actor_market::{ | ||
Actor as MarketActor, ClientDealProposal, Method, PublishStorageDealsParams, | ||
}; | ||
use fil_actors_runtime::network::EPOCHS_IN_DAY; | ||
use fil_actors_runtime::test_utils::*; | ||
use fil_actors_runtime::BURNT_FUNDS_ACTOR_ADDR; | ||
use fvm_ipld_encoding::RawBytes; | ||
use fvm_shared::clock::ChainEpoch; | ||
use fvm_shared::crypto::signature::Signature; | ||
use fvm_shared::econ::TokenAmount; | ||
use fvm_shared::error::ExitCode; | ||
use fvm_shared::METHOD_SEND; | ||
|
||
use fil_actor_market::ext::account::{AuthenticateMessageParams, AUTHENTICATE_MESSAGE_METHOD}; | ||
use fvm_ipld_encoding::ipld_block::IpldBlock; | ||
use fvm_shared::sys::SendFlags; | ||
use num_traits::Zero; | ||
|
||
mod harness; | ||
|
||
use harness::*; | ||
|
||
const START_EPOCH: ChainEpoch = 50; | ||
const END_EPOCH: ChainEpoch = START_EPOCH + 200 * EPOCHS_IN_DAY; | ||
|
||
#[test] | ||
fn timedout_deal_is_slashed_and_deleted() { | ||
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); | ||
|
||
let c_escrow = get_balance(&rt, &CLIENT_ADDR).balance; | ||
|
||
// do a cron tick for it -> should time out and get slashed | ||
rt.set_epoch(process_epoch(START_EPOCH, deal_id)); | ||
rt.expect_send_simple( | ||
BURNT_FUNDS_ACTOR_ADDR, | ||
METHOD_SEND, | ||
None, | ||
deal_proposal.provider_collateral.clone(), | ||
None, | ||
ExitCode::OK, | ||
); | ||
|
||
process_deal_updates(&rt, CLIENT_ADDR, vec![deal_id]); | ||
|
||
let client_acct = get_balance(&rt, &CLIENT_ADDR); | ||
assert_eq!(c_escrow, client_acct.balance); | ||
assert!(client_acct.locked.is_zero()); | ||
assert_account_zero(&rt, PROVIDER_ADDR); | ||
assert_deal_deleted(&rt, deal_id, deal_proposal); | ||
|
||
check_state(&rt); | ||
} |