-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test for transfer manager erc1155
- Loading branch information
Showing
6 changed files
with
96 additions
and
31 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
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,30 @@ | ||
#[starknet::interface] | ||
trait IERC1155<TContractState> { | ||
fn safe_transfer_from( | ||
ref self: TContractState, | ||
from: starknet::ContractAddress, | ||
to: starknet::ContractAddress, | ||
id: u256, | ||
amount: u128, | ||
data: Span<felt252> | ||
); | ||
} | ||
|
||
#[starknet::contract] | ||
mod ERC1155 { | ||
#[storage] | ||
struct Storage {} | ||
|
||
#[external(v0)] | ||
impl ERC1155Impl of super::IERC1155<ContractState> { | ||
fn safe_transfer_from( | ||
ref self: ContractState, | ||
from: starknet::ContractAddress, | ||
to: starknet::ContractAddress, | ||
id: u256, | ||
amount: u128, | ||
data: Span<felt252> | ||
) {} | ||
} | ||
} | ||
|
52 changes: 39 additions & 13 deletions
52
flex_marketplace/tests/transfer_manager_erc1155_test.cairo
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 |
---|---|---|
@@ -1,32 +1,58 @@ | ||
use tests::utils::{setup, initialize_test}; | ||
use snforge_std::{start_prank, stop_prank, PrintTrait, CheatTarget}; | ||
|
||
use flex::marketplace::transfer_manager_ERC1155::{ | ||
IERC1155TransferManagerDispatcher, IERC1155TransferManagerDispatcherTrait | ||
}; | ||
use tests::utils::{ | ||
setup, initialize_test, ACCOUNT1, ACCOUNT2, OWNER, ZERO_ADDRESS, deploy_mock_1155 | ||
}; | ||
|
||
const TOKEN_ID: u256 = 1; | ||
|
||
#[test] | ||
fn test_transfer_non_fungible_token_success() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
let collection = deploy_mock_1155(); | ||
|
||
start_prank( | ||
CheatTarget::One(dsp.transfer_manager_erc1155.contract_address), | ||
dsp.marketplace.contract_address | ||
); | ||
dsp | ||
.transfer_manager_erc1155 | ||
.transfer_non_fungible_token( | ||
collection, ACCOUNT1(), ACCOUNT2(), TOKEN_ID, 1, array![].span() | ||
); | ||
} | ||
|
||
#[test] | ||
#[should_panic()] | ||
#[should_panic(expected: ("ERC1155TransferManager: caller 0 is not marketplace",))] | ||
fn test_transfer_non_fungible_token_fails_caller_not_marketplace() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
assert(false, ''); | ||
// TODO | ||
let collection = deploy_mock_1155(); | ||
|
||
start_prank(CheatTarget::One(dsp.transfer_manager_erc1155.contract_address), ZERO_ADDRESS()); | ||
dsp | ||
.transfer_manager_erc1155 | ||
.transfer_non_fungible_token( | ||
collection, ACCOUNT1(), ACCOUNT2(), TOKEN_ID, 1, array![].span() | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_update_marketplace_success() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
} | ||
let collection = deploy_mock_1155(); | ||
let new_marketplace = starknet::contract_address_const::<'new_marketplace'>(); | ||
|
||
// TESTS VIEWS | ||
#[test] | ||
fn test_get_marketplace() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
start_prank(CheatTarget::One(dsp.transfer_manager_erc1155.contract_address), OWNER()); | ||
dsp.transfer_manager_erc1155.update_marketplace(new_marketplace); | ||
|
||
let actual_marketplace = dsp.transfer_manager_erc1155.get_marketplace(); | ||
|
||
assert(actual_marketplace == new_marketplace, 'update marketplace failed'); | ||
} | ||
|
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