Skip to content

Commit

Permalink
update test to reflect new validation behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Oct 13, 2024
1 parent d6ce634 commit 4d99a79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/katana/contracts/build/default_account.json

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions crates/katana/rpc/rpc/tests/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,21 @@ async fn send_txs_with_insufficient_fee(
let res = contract.transfer(&recipient, &amount).max_fee(Felt::TWO).send().await;

if disable_fee {
// in no fee mode, setting the max fee (which translates to the tx run resources) lower
// than the amount required would result in a validation failure. due to insufficient
// resources.
assert_starknet_err!(res.unwrap_err(), StarknetError::ValidationFailure(_));
// In no fee mode, the transaction resources (ie max fee) is totally ignored. So doesn't matter
// what value is set, the transaction will always be executed successfully.
assert_matches!(res, Ok(tx) => {
let tx_hash = tx.transaction_hash;
assert_matches!(dojo_utils::TransactionWaiter::new(tx_hash, &sequencer.provider()).await, Ok(_));
});

let nonce = sequencer.account().get_nonce().await?;
assert_eq!(initial_nonce + 1, nonce, "Nonce should change in fee-disabled mode");
} else {
assert_starknet_err!(res.unwrap_err(), StarknetError::InsufficientMaxFee);
let nonce = sequencer.account().get_nonce().await?;
assert_eq!(initial_nonce, nonce, "Nonce shouldn't change in fee-enabled mode");
}

let nonce = sequencer.account().get_nonce().await?;
assert_eq!(initial_nonce, nonce, "Nonce shouldn't change after invalid tx");

// -----------------------------------------------------------------------
// transaction with insufficient balance.

Expand All @@ -435,13 +439,13 @@ async fn send_txs_with_insufficient_fee(

// nonce should be incremented by 1 after a valid tx.
let nonce = sequencer.account().get_nonce().await?;
assert_eq!(initial_nonce + 1, nonce);
assert_eq!(initial_nonce + 2, nonce, "Nonce should change in fee-disabled mode");
} else {
assert_starknet_err!(res.unwrap_err(), StarknetError::InsufficientAccountBalance);

// nonce shouldn't change for an invalid tx.
let nonce = sequencer.account().get_nonce().await?;
assert_eq!(initial_nonce, nonce);
assert_eq!(initial_nonce, nonce, "Nonce shouldn't change in fee-enabled mode");
}

Ok(())
Expand Down

0 comments on commit 4d99a79

Please sign in to comment.