diff --git a/pop-api/examples/fungibles/tests.rs b/pop-api/examples/fungibles/tests.rs index 33ee18bd..57e93005 100644 --- a/pop-api/examples/fungibles/tests.rs +++ b/pop-api/examples/fungibles/tests.rs @@ -268,15 +268,19 @@ fn transfer_fails_with_insufficient_balance( const AMOUNT: Balance = TOKEN_MIN_BALANCE * 4; assert_ok!(session.sandbox().mint_into(&TOKEN_ID, &contract.clone(), AMOUNT)); assert_ok!(session.sandbox().mint_into(&TOKEN_ID, &BOB, AMOUNT)); + assert_eq!(session.sandbox().balance_of(&TOKEN_ID, &contract.clone()), AMOUNT); session.set_actor(contract.clone()); // Failed with `InsufficientBalance`. + let data = serde_json::to_string::<[u8; 0]>(&[]).unwrap(); expect_call_reverted( &mut session, TRANSFER, - vec![BOB.to_string(), (AMOUNT + 1).to_string()], + vec![BOB.to_string(), (AMOUNT + 1).to_string(), data], PSP22Error::InsufficientBalance, ); + // Check that balance of account is not changed. + assert_eq!(session.sandbox().balance_of(&TOKEN_ID, &contract), AMOUNT); Ok(()) } diff --git a/pop-api/examples/fungibles/utils.rs b/pop-api/examples/fungibles/utils.rs index 44755f8b..fb6a1e3f 100644 --- a/pop-api/examples/fungibles/utils.rs +++ b/pop-api/examples/fungibles/utils.rs @@ -39,7 +39,7 @@ pub(super) fn last_contract_event(session: &Session) -> Option> session.record().last_event_batch().contract_events().last().cloned() } -/// Execute a contract method and exepct CallReverted error to be returned. +/// Execute a contract method and expect CallReverted error to be returned. pub(super) fn expect_call_reverted( session: &mut Session, function: &str, @@ -47,8 +47,11 @@ pub(super) fn expect_call_reverted( err: PSP22Error, ) { let call = session.call::(function, ¶ms, None); - if let Err(SessionError::CallReverted(error)) = call { - assert_eq!(error[1..], Err::<(), PSP22Error>(err).encode()); + match call { + Err(SessionError::CallReverted(error)) => { + assert_eq!(error[1..], Err::<(), PSP22Error>(err).encode()) + }, + _ => panic!("Expect call reverted"), } }