Skip to content

Commit

Permalink
should panic if wrong owner try to burn token
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Oct 4, 2024
1 parent 021111b commit f1fac12
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apps/blockchain/starknet/src/token/erc721_bridgeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,34 @@ mod tests {

}

/// Should panic, only owner can burn
#[test]
#[should_panic(expected: ('ERC721: only owner can burn', ))]
fn should_panic_burn_from_bridge() {
let BRIDGE = bridge_addr_mock();

let DUO_OWNER = starknet::contract_address_const::<128>();

let contract_address = deploy_everai_collection();

let erc721b = IERC721BridgeableDispatcher { contract_address };

// Mint a token first to be able to burn it later
start_prank(CheatTarget::One(contract_address), BRIDGE);
erc721b.mint_from_bridge(DUO_OWNER, 42_u256);
stop_prank(CheatTarget::One(contract_address));

// Check that the owner is set correctly after minting
let erc721 = IERC721Dispatcher { contract_address };
assert!(erc721.owner_of(42_u256) == DUO_OWNER, "bad owner after mint");

// Burn the token by wrong owner
start_prank(CheatTarget::One(contract_address), BRIDGE);
erc721b.burn(42_u256);


}

/// Should not mint token if not bridge.
#[test]
#[should_panic(expected: ('ERC721: only bridge can mint', ))]
Expand Down

0 comments on commit f1fac12

Please sign in to comment.