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

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Dec 7, 2023
1 parent a216899 commit 5b39faa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
11 changes: 7 additions & 4 deletions crates/pallets/starknet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,10 @@ impl<T: Config> Pallet<T> {
UserTransaction::Invoke(_) => TransactionTrace::Invoke(InvokeTransactionTrace {
validate_invocation,
execute_invocation: convert_call_info_to_execute_invocation::<T>(
tx_exec_info.execute_call_info.as_ref().ok_or(Error::<T>::MissingCallInfo)?,
tx_exec_info
.execute_call_info
.as_ref()
.ok_or(Error::<T>::TransactionExecutionFailed)?,
tx_exec_info.revert_error.as_ref(),
)?,
fee_transfer_invocation,
Expand All @@ -1147,7 +1150,7 @@ impl<T: Config> Pallet<T> {
constructor_invocation: tx_exec_info
.execute_call_info
.as_ref()
.ok_or(Error::<T>::MissingCallInfo)?
.ok_or(Error::<T>::TransactionExecutionFailed)?
.into(),

fee_transfer_invocation,
Expand All @@ -1158,9 +1161,9 @@ impl<T: Config> Pallet<T> {
.execute_call_info
.as_ref()
.map(|x| x.execution.gas_consumed)
.ok_or(Error::<T>::MissingCallInfo)?;
.ok_or(Error::<T>::TransactionExecutionFailed)?;
let overall_fee = tx_exec_info.actual_fee.0 as u64;
let gas_price = overall_fee / gas_consumed;
let gas_price = if gas_consumed > 0 { overall_fee / gas_consumed } else { 0 };
results.push(SimulatedTransaction {
transaction_trace,
fee_estimation: FeeEstimate { gas_consumed, gas_price, overall_fee },
Expand Down
12 changes: 4 additions & 8 deletions starknet-rpc-test/simulate_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ async fn works_ok_on_no_validate(madara: &ThreadSafeMadaraClient) -> Result<(),
.await?;

assert_eq!(simulations.len(), 2);
// TODO update
assert_eq!(simulations[0].fee_estimation.gas_consumed, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 420);
assert_eq!(simulations[0].fee_estimation.gas_price, 0);

Ok(())
Expand All @@ -164,9 +163,8 @@ async fn works_ok_on_validate_with_signature(madara: &ThreadSafeMadaraClient) ->
let simulations = rpc.simulate_transactions(BlockId::Tag(BlockTag::Latest), &[invoke_transaction], []).await?;

assert_eq!(simulations.len(), 1);
// TODO update
assert_eq!(simulations[0].fee_estimation.gas_consumed, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 480);
assert_eq!(simulations[0].fee_estimation.gas_price, 0);

Ok(())
Expand Down Expand Up @@ -196,9 +194,8 @@ async fn works_ok_on_validate_without_signature_with_skip_validate(
.await?;

assert_eq!(simulations.len(), 1);
// TODO update
assert_eq!(simulations[0].fee_estimation.gas_consumed, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 440);
assert_eq!(simulations[0].fee_estimation.gas_price, 0);

Ok(())
Expand Down Expand Up @@ -237,9 +234,8 @@ async fn works_ok_without_max_fee_with_skip_fee_charge(madara: &ThreadSafeMadara
.await?;

assert_eq!(simulations.len(), 2);
// TODO update
assert_eq!(simulations[0].fee_estimation.gas_consumed, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 0);
assert_eq!(simulations[0].fee_estimation.overall_fee, 420);
assert_eq!(simulations[0].fee_estimation.gas_price, 0);

Ok(())
Expand Down
4 changes: 1 addition & 3 deletions starknet-rpc-test/spec_version.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
extern crate starknet_rpc_test;

use rstest::rstest;
use starknet_providers::Provider;
use starknet_rpc_test::constants::SPEC_VERSION;
use starknet_rpc_test::fixtures::{madara, ThreadSafeMadaraClient};

#[rstest]
#[tokio::test]
#[ignore = "Waiting for starknet_providers::jsonrpc upgrade to v0.6.0"]
async fn returns_hardcoded_spec_version(madara: &ThreadSafeMadaraClient) -> Result<(), anyhow::Error> {
let rpc = madara.get_starknet_client().await;
madara.get_starknet_client().await;

// TODO: test it when starknet_providers::jsonrpc upgrades to v0.6.0
// assert_eq!(rpc.spec_version().await?, SPEC_VERSION);
Expand Down
4 changes: 1 addition & 3 deletions starknet-rpc-test/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use starknet_accounts::{
use starknet_core::chain_id;
use starknet_core::types::contract::legacy::LegacyContractClass;
use starknet_core::types::contract::{CompiledClass, SierraClass};
use starknet_core::types::{
BlockId, BlockTag, BroadcastedInvokeTransaction, EmittedEvent, Event, FieldElement, FunctionCall, MsgToL1,
};
use starknet_core::types::{BlockId, BlockTag, BroadcastedInvokeTransaction, FieldElement, FunctionCall, MsgToL1};
use starknet_core::utils::get_selector_from_name;
use starknet_providers::jsonrpc::{HttpTransport, JsonRpcClient};
use starknet_providers::Provider;
Expand Down

0 comments on commit 5b39faa

Please sign in to comment.