Skip to content

Commit

Permalink
contracts: WIP cancel_order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptisserand committed Sep 14, 2024
1 parent 8c0f17c commit 85a53de
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions contracts/ark_starknet/tests/integration/cancel_order.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use ark_common::protocol::order_types::CancelInfo;

use ark_starknet::interfaces::{
IExecutorDispatcher, IExecutorDispatcherTrait, IMaintenanceDispatcher,
IMaintenanceDispatcherTrait
};

use snforge_std::{cheat_caller_address, CheatSpan, spy_events, EventSpyAssertionsTrait,};

use starknet::{ContractAddress, contract_address_const};
use super::super::common::setup::{
create_auction_order, create_collection_offer_order, create_listing_order, create_offer_order,
setup, setup_default_order, setup_auction_order, setup_collection_offer_order,
setup_listing_order, setup_offer_order
};

#[test]
fn test_cancel_offer_order() {
let (executor_address, erc20_address, nft_address) = setup();
let token_id = 10;

let (order_hash, offerer, start_amount) = create_offer_order(
executor_address, erc20_address, nft_address, token_id
);

let cancel_info = CancelInfo {
order_hash,
canceller: offerer,
token_chain_id: 'SN_MAIN',
token_address: nft_address,
token_id: Option::Some(token_id),
};

cheat_caller_address(executor_address, offerer, CheatSpan::TargetCalls(1));
IExecutorDispatcher { contract_address: executor_address }.cancel_order(cancel_info);
}

// #[test]
// fn test_cancel_listing_order() {}
//
// #[test]
// fn test_cancel_auction_order() {}
//
// #[test]
// fn test_cancel_collection_offer_order() {}

#[test]
#[should_panic]
fn test_cancel_offer_order_only_offerer() {
let (executor_address, erc20_address, nft_address) = setup();
let token_id = 10;
let other = contract_address_const::<'other'>();

let (order_hash, offerer, start_amount) = create_offer_order(
executor_address, erc20_address, nft_address, token_id
);

let cancel_info = CancelInfo {
order_hash,
canceller: offerer,
token_chain_id: 'SN_MAIN',
token_address: nft_address,
token_id: Option::Some(token_id),
};

cheat_caller_address(executor_address, other, CheatSpan::TargetCalls(1));
IExecutorDispatcher { contract_address: executor_address }.cancel_order(cancel_info);
}
1 change: 1 addition & 0 deletions contracts/ark_starknet/tests/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod unit {
mod test_fees;
}
mod integration {
mod cancel_order;
mod create_order;
// mod execute_order;
mod fees_amount;
Expand Down

0 comments on commit 85a53de

Please sign in to comment.