-
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.
Merge pull request #46 from ametel01/TM-erc721-tests
Added Test for TM ERC721
- Loading branch information
Showing
5 changed files
with
80 additions
and
16 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,27 @@ | ||
#[starknet::interface] | ||
trait IER721CamelOnly<TState> { | ||
fn transferFrom( | ||
ref self: TState, | ||
from: starknet::ContractAddress, | ||
to: starknet::ContractAddress, | ||
token_id: u256 | ||
); | ||
} | ||
|
||
#[starknet::contract] | ||
mod ERC721 { | ||
use starknet::{ContractAddress, get_caller_address}; | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
#[external(v0)] | ||
impl IERC721CamelOnlyImpl of super::IER721CamelOnly<ContractState> { | ||
fn transferFrom( | ||
ref self: ContractState, | ||
from: starknet::ContractAddress, | ||
to: starknet::ContractAddress, | ||
token_id: u256 | ||
) {} | ||
} | ||
} |
49 changes: 36 additions & 13 deletions
49
flex_marketplace/tests/transfer_manager_erc721_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,33 +1,56 @@ | ||
use tests::utils::{setup, initialize_test}; | ||
use snforge_std::{start_prank, stop_prank, PrintTrait, CheatTarget}; | ||
use tests::utils::{ | ||
setup, initialize_test, deploy_mock_nft, ACCOUNT1, ACCOUNT2, OWNER, ZERO_ADDRESS | ||
}; | ||
use flex::marketplace::transfer_manager_ERC721::{ | ||
ITransferManagerNFTDispatcher, ITransferManagerNFTDispatcherTrait | ||
}; | ||
|
||
const TOKEN_ID: u256 = 1; | ||
|
||
#[test] | ||
fn test_transfer_non_fungible_token_success() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
let collection = deploy_mock_nft(); | ||
|
||
start_prank( | ||
CheatTarget::One(dsp.transfer_manager_erc721.contract_address), | ||
dsp.marketplace.contract_address | ||
); | ||
dsp | ||
.transfer_manager_erc721 | ||
.transfer_non_fungible_token(collection, ACCOUNT1(), ACCOUNT2(), TOKEN_ID, 1); | ||
} | ||
|
||
#[test] | ||
#[should_panic()] | ||
#[should_panic(expected: ("TransferManagerNFT: 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_nft(); | ||
|
||
start_prank(CheatTarget::One(dsp.transfer_manager_erc721.contract_address), ZERO_ADDRESS()); | ||
dsp | ||
.transfer_manager_erc721 | ||
.transfer_non_fungible_token(collection, ACCOUNT1(), ACCOUNT2(), TOKEN_ID, 1); | ||
} | ||
|
||
#[test] | ||
fn test_update_marketplace_success() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
} | ||
let collection = deploy_mock_nft(); | ||
let new_marketplace = starknet::contract_address_const::<'new_marketplace'>(); | ||
|
||
start_prank( | ||
CheatTarget::One(dsp.transfer_manager_erc721.contract_address), | ||
dsp.marketplace.contract_address | ||
); | ||
dsp.transfer_manager_erc721.update_marketplace(new_marketplace); | ||
|
||
// TESTS VIEWSqs | ||
#[test] | ||
fn test_get_marketplace() { | ||
let dsp = setup(); | ||
initialize_test(dsp); | ||
// TODO | ||
let actual_marketplace = dsp.transfer_manager_erc721.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