Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
test: estime_fee skip validation (#1584)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven <steven@Stevens-Mac.local>
  • Loading branch information
stevencartavia and Steven authored May 16, 2024
1 parent b5f893f commit e530bae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- dev: pallet test for estimate_fee that skip validation
- feat: add versioned constants to pallet constants
- bug: fix contract serialisation
- fix: starknet_call errs if contract nonexistent
Expand Down
22 changes: 22 additions & 0 deletions crates/pallets/starknet/src/tests/query_tx.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use blockifier::transaction::account_transaction::AccountTransaction;
use frame_support::{assert_err, assert_ok};
use mp_simulations::SimulationFlags;
use mp_transactions::compute_hash::ComputeTransactionHash;
use starknet_api::core::Nonce;
use starknet_api::hash::StarkFelt;
Expand Down Expand Up @@ -97,3 +98,24 @@ fn query_tx_should_not_be_executable() {
);
});
}

#[test]
fn estimate_fee_skips_validation_for_invalid_tx() {
new_test_ext::<MockRuntime>().execute_with(|| {
basic_test_setup(2);

// // Invalid nonce (actual: 42, expected: 0)
let invalid_transaction = get_invoke_dummy(Starknet::chain_id(), Nonce(StarkFelt::from(42u64)));
let tx = AccountTransaction::Invoke(invalid_transaction.clone());

let tx_vec = vec![tx.clone()];

let fee_estimation_result =
Starknet::estimate_fee(tx_vec.clone(), &SimulationFlags { validate: true, charge_fee: true });
assert!(fee_estimation_result.unwrap().is_err(), "Fee estimation succeded");

let fee_estimation_result =
Starknet::estimate_fee(tx_vec.clone(), &SimulationFlags { validate: false, charge_fee: true });
assert!(fee_estimation_result.is_ok(), "Fee estimation failed unexpectedly");
});
}

0 comments on commit e530bae

Please sign in to comment.