Skip to content

Commit

Permalink
Add test to check immediate caller
Browse files Browse the repository at this point in the history
  • Loading branch information
darthsiroftardis committed Jun 14, 2022
1 parent 2726a86 commit 82004b7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 0 additions & 2 deletions contract/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ pub enum OwnershipMode {
Assigned = 1,
/// The NFT can be transferred even to an recipient that does not exist.
Transferable = 2,
// TODO
// Platform = 3,
}

impl TryFrom<u8> for OwnershipMode {
Expand Down
36 changes: 36 additions & 0 deletions tests/src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,3 +1330,39 @@ fn should_mint_with_hash_identifier_mode() {

assert_eq!(vec![token_id_hash], actual_token_ids);
}

#[test]
fn should_fail_to_mint_when_immediate_caller_is_account_in_contract_mode() {
let mut builder = InMemoryWasmTestBuilder::default();
builder.run_genesis(&DEFAULT_RUN_GENESIS_REQUEST).commit();

let install_request =
InstallerRequestBuilder::new(*DEFAULT_ACCOUNT_ADDR, NFT_CONTRACT_WASM)
.with_total_token_supply(2u64)
.with_holder_mode(NFTHolderMode::Contracts)
.with_whitelist_mode(WhitelistMode::Unlocked)
.build();

builder.exec(install_request).expect_success().commit();

let nft_contract_key: Key = get_nft_contract_hash(&builder).into();

let mint_session_call = ExecuteRequestBuilder::standard(
*DEFAULT_ACCOUNT_ADDR,
MINT_SESSION_WASM,
runtime_args! {
ARG_NFT_CONTRACT_HASH => nft_contract_key,
ARG_TOKEN_OWNER => Key::Account(*DEFAULT_ACCOUNT_ADDR),
ARG_TOKEN_META_DATA => TEST_COMPACT_META_DATA,
},
)
.build();

builder
.exec(mint_session_call)
.expect_failure();

let error = builder.get_error().expect("must have error");

assert_expected_error(error, 76, "InvalidHolderMode(76) must have been raised");
}

0 comments on commit 82004b7

Please sign in to comment.