diff --git a/unit_tests/tests/common.rs b/unit_tests/tests/common.rs index b9c2781..ebed895 100644 --- a/unit_tests/tests/common.rs +++ b/unit_tests/tests/common.rs @@ -36,15 +36,6 @@ pub fn checking_error_format(response: &ProviderError, expected_error: StarknetE } } -// pub fn get_block_setting() -> BlockId { -// let max_block = BlockId::Number(*MAX_BLOCK); -// if *MAX_BLOCK == 0 { -// BlockId::Tag(starknet_core::types::BlockTag::Latest) -// } else { -// max_block -// } -// } - // TODO : Maybe create a function for each executions call that retrieves // responses from the 3 differents full nodes and compare releveant fields diff --git a/unit_tests/tests/test_call.rs b/unit_tests/tests/test_call.rs index 46ecb71..08f6048 100644 --- a/unit_tests/tests/test_call.rs +++ b/unit_tests/tests/test_call.rs @@ -234,7 +234,6 @@ async fn fail_invalid_contract_call_data(clients: HashMap .await .expect("Error waiting for response from Pathfinder node"); - println!("✅{:?}", response_deoxys); - println!("✅{:?}", response_pathfinder); - let response_expected = short_string!("Ether"); assert_eq!(response_deoxys, vec![response_expected]); diff --git a/unit_tests/tests/test_deploy_account_transaction.rs b/unit_tests/tests/test_deploy_account_transaction.rs index 6b3630e..768fb44 100644 --- a/unit_tests/tests/test_deploy_account_transaction.rs +++ b/unit_tests/tests/test_deploy_account_transaction.rs @@ -1,161 +1,161 @@ -#![feature(assert_matches)] - -mod common; -use common::*; -use starknet_core::types::{ - BroadcastedDeployAccountTransaction, FieldElement, StarknetError, TransactionStatus, -}; -use starknet_providers::{ - jsonrpc::{HttpTransport, JsonRpcClient}, - Provider, ProviderError, -}; -use std::assert_matches::assert_matches; -use std::thread; -use std::time::Duration; - -/// Test for the `deploy_account_transaction` Deoxys RPC method -/// Submit a new deploy account transaction -/// -/// There is two type of DeployAccountTransaction: V1 and V3 -/// -/// # Arguments -/// * `deploy_account_transaction` - A deploy account transaction -/// with following fields (V1): -/// * `type` - DEPLOY_ACCOUNT -/// * `max_fee` - The maximal fee willing to be paid -/// * `signature` - The transaction signature -/// * `nonce` - The nonce of the transaction -/// * `contract_address_salt` - The salt for the address of the deployed contract -/// * `constructor_calldata` - The parameters passed to the constructor -/// * `class_hash` - The hash of the deployed contract's class -/// * `is_query` - If set to `true`, uses a query-only transaction version that's invalid for execution -/// -/// # Returns -/// * `result` - The result of the transaction submission -/// with following fields: -/// * `transaction_hash` - The hash of the transaction -/// * `contract_address` - The address of the deployed contract -/// -/// # Errors -/// * `invalid_transaction_nonce` - If the transaction nonce is invalid -/// * `insufficient_account_balance` - If the account balance is insufficient -/// * `insufficient_max_fee` - If the max fee is insufficient -/// * `invalid_transaction_nonce` - If the transaction nonce is invalid -/// * `validation_failure` - If the transaction validation fails -/// * `non_account` - If the sender address is not a valid account -/// * `duplicate_transaction` - If a transaction with same params already exists -/// * `unsupported_transaction_version` - If the transaction version is not supported -/// * `unexpected_error` - If an unexpected error occurs - -#[ignore = "For this one, you need to submit a valid account (private key) and address"] -#[rstest] -#[tokio::test] -async fn fail_if_param_(deoxys: JsonRpcClient) { - let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { - max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), - signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], - nonce: FieldElement::from_hex_be("0x000000").unwrap(), //here nonce is invalid - contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), - constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], - class_hash: FieldElement::from_hex_be("0x000000").unwrap(), - is_query: false, - }; - - let response_deoxys = deoxys - .add_deploy_account_transaction(invalid_deploy_account_transaction) - .await; - - assert_matches!( - response_deoxys, - Err(ProviderError::StarknetError( - StarknetError::InvalidTransactionNonce - )) - ); -} - -#[ignore = "For this one, you need to submit a valid account (private key) and address"] -#[rstest] -#[tokio::test] -async fn fail_if_insufficient_max_fee(deoxys: JsonRpcClient) { - let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { - max_fee: FieldElement::from_hex_be("0x000000").unwrap(), //here max_fee is insufficient - signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], - nonce: FieldElement::from_hex_be("0x000000").unwrap(), - contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), - constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], - class_hash: FieldElement::from_hex_be("0x000000").unwrap(), - is_query: false, - }; - - let response_deoxys = deoxys - .add_deploy_account_transaction(invalid_deploy_account_transaction) - .await; - - assert_matches!( - response_deoxys, - Err(ProviderError::StarknetError( - StarknetError::InsufficientMaxFee - )) - ); -} - -#[ignore = "For this one, you need to submit a valid account (private key) and address"] -#[rstest] -#[tokio::test] -async fn fail_if_invalid_transaction_nonce(deoxys: JsonRpcClient) { - let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { - max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), - signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], - nonce: FieldElement::from_hex_be("0x000000").unwrap(), //here nonce is invalid - contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), - constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], - class_hash: FieldElement::from_hex_be("0x000000").unwrap(), - is_query: false, - }; - - let response_deoxys = deoxys - .add_deploy_account_transaction(invalid_deploy_account_transaction) - .await; - - assert_matches!( - response_deoxys, - Err(ProviderError::StarknetError( - StarknetError::InvalidTransactionNonce - )) - ); -} - -#[ignore = "For this one, you need to submit a valid account (private key) and address"] -#[rstest] -#[tokio::test] -async fn works_ok(deoxys: JsonRpcClient) { - let valid_deploy_account_transaction = BroadcastedDeployAccountTransaction { - max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), - signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], - nonce: FieldElement::from_hex_be("0x000000").unwrap(), - contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), - constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], - class_hash: FieldElement::from_hex_be("0x000000").unwrap(), - is_query: false, - }; - - let response_deoxys = deoxys - .add_deploy_account_transaction(valid_deploy_account_transaction) - .await; - - //Here, as response we got the transaction hash and the contract address deployed - let result = response_deoxys.expect("Error in the transaction submission"); - - //Now, if the transaction is valid, the rpc call response contain the transaction hash - let transaction_submitted_hash = result.transaction_hash; - - //Wait for the transaction to be added to the chain - thread::sleep(Duration::from_secs(15)); - - //Let's check the transaction status - let transaction_status = deoxys - .get_transaction_status(transaction_submitted_hash) - .await; - - assert_matches!(transaction_status.unwrap(), TransactionStatus::Received); -} +// #![feature(assert_matches)] + +// mod common; +// use common::*; +// use starknet_core::types::{ +// BroadcastedDeployAccountTransaction, FieldElement, StarknetError, TransactionStatus, +// }; +// use starknet_providers::{ +// jsonrpc::{HttpTransport, JsonRpcClient}, +// Provider, ProviderError, +// }; +// use std::assert_matches::assert_matches; +// use std::thread; +// use std::time::Duration; + +// /// Test for the `deploy_account_transaction` Deoxys RPC method +// /// Submit a new deploy account transaction +// /// +// /// There is two type of DeployAccountTransaction: V1 and V3 +// /// +// /// # Arguments +// /// * `deploy_account_transaction` - A deploy account transaction +// /// with following fields (V1): +// /// * `type` - DEPLOY_ACCOUNT +// /// * `max_fee` - The maximal fee willing to be paid +// /// * `signature` - The transaction signature +// /// * `nonce` - The nonce of the transaction +// /// * `contract_address_salt` - The salt for the address of the deployed contract +// /// * `constructor_calldata` - The parameters passed to the constructor +// /// * `class_hash` - The hash of the deployed contract's class +// /// * `is_query` - If set to `true`, uses a query-only transaction version that's invalid for execution +// /// +// /// # Returns +// /// * `result` - The result of the transaction submission +// /// with following fields: +// /// * `transaction_hash` - The hash of the transaction +// /// * `contract_address` - The address of the deployed contract +// /// +// /// # Errors +// /// * `invalid_transaction_nonce` - If the transaction nonce is invalid +// /// * `insufficient_account_balance` - If the account balance is insufficient +// /// * `insufficient_max_fee` - If the max fee is insufficient +// /// * `invalid_transaction_nonce` - If the transaction nonce is invalid +// /// * `validation_failure` - If the transaction validation fails +// /// * `non_account` - If the sender address is not a valid account +// /// * `duplicate_transaction` - If a transaction with same params already exists +// /// * `unsupported_transaction_version` - If the transaction version is not supported +// /// * `unexpected_error` - If an unexpected error occurs + +// #[ignore = "For this one, you need to submit a valid account (private key) and address"] +// #[rstest] +// #[tokio::test] +// async fn fail_if_param_(deoxys: JsonRpcClient) { +// let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { +// max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), +// signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], +// nonce: FieldElement::from_hex_be("0x000000").unwrap(), //here nonce is invalid +// contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), +// constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], +// class_hash: FieldElement::from_hex_be("0x000000").unwrap(), +// is_query: false, +// }; + +// let response_deoxys = deoxys +// .add_deploy_account_transaction(invalid_deploy_account_transaction) +// .await; + +// assert_matches!( +// response_deoxys, +// Err(ProviderError::StarknetError( +// StarknetError::InvalidTransactionNonce +// )) +// ); +// } + +// #[ignore = "For this one, you need to submit a valid account (private key) and address"] +// #[rstest] +// #[tokio::test] +// async fn fail_if_insufficient_max_fee(deoxys: JsonRpcClient) { +// let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { +// max_fee: FieldElement::from_hex_be("0x000000").unwrap(), //here max_fee is insufficient +// signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], +// nonce: FieldElement::from_hex_be("0x000000").unwrap(), +// contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), +// constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], +// class_hash: FieldElement::from_hex_be("0x000000").unwrap(), +// is_query: false, +// }; + +// let response_deoxys = deoxys +// .add_deploy_account_transaction(invalid_deploy_account_transaction) +// .await; + +// assert_matches!( +// response_deoxys, +// Err(ProviderError::StarknetError( +// StarknetError::InsufficientMaxFee +// )) +// ); +// } + +// #[ignore = "For this one, you need to submit a valid account (private key) and address"] +// #[rstest] +// #[tokio::test] +// async fn fail_if_invalid_transaction_nonce(deoxys: JsonRpcClient) { +// let invalid_deploy_account_transaction = BroadcastedDeployAccountTransaction { +// max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), +// signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], +// nonce: FieldElement::from_hex_be("0x000000").unwrap(), //here nonce is invalid +// contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), +// constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], +// class_hash: FieldElement::from_hex_be("0x000000").unwrap(), +// is_query: false, +// }; + +// let response_deoxys = deoxys +// .add_deploy_account_transaction(invalid_deploy_account_transaction) +// .await; + +// assert_matches!( +// response_deoxys, +// Err(ProviderError::StarknetError( +// StarknetError::InvalidTransactionNonce +// )) +// ); +// } + +// #[ignore = "For this one, you need to submit a valid account (private key) and address"] +// #[rstest] +// #[tokio::test] +// async fn works_ok(deoxys: JsonRpcClient) { +// let valid_deploy_account_transaction = BroadcastedDeployAccountTransaction { +// max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), +// signature: vec![FieldElement::from_hex_be("signature_array").unwrap()], +// nonce: FieldElement::from_hex_be("0x000000").unwrap(), +// contract_address_salt: FieldElement::from_hex_be("0x000000").unwrap(), +// constructor_calldata: vec![FieldElement::from_hex_be("constructor_calldata_array").unwrap()], +// class_hash: FieldElement::from_hex_be("0x000000").unwrap(), +// is_query: false, +// }; + +// let response_deoxys = deoxys +// .add_deploy_account_transaction(valid_deploy_account_transaction) +// .await; + +// //Here, as response we got the transaction hash and the contract address deployed +// let result = response_deoxys.expect("Error in the transaction submission"); + +// //Now, if the transaction is valid, the rpc call response contain the transaction hash +// let transaction_submitted_hash = result.transaction_hash; + +// //Wait for the transaction to be added to the chain +// thread::sleep(Duration::from_secs(15)); + +// //Let's check the transaction status +// let transaction_status = deoxys +// .get_transaction_status(transaction_submitted_hash) +// .await; + +// assert_matches!(transaction_status.unwrap(), TransactionStatus::Received); +// } diff --git a/unit_tests/tests/test_estimate_fee.rs b/unit_tests/tests/test_estimate_fee.rs index 8b9a62a..ccfc8aa 100644 --- a/unit_tests/tests/test_estimate_fee.rs +++ b/unit_tests/tests/test_estimate_fee.rs @@ -21,11 +21,12 @@ async fn fail_non_existing_block(clients: HashMap>) { let ok_pathfinder_invoke_1 = OkTransactionFactory::build(Some(FieldElement::ONE)); let ok_pathfinder_invoke_2 = OkTransactionFactory::build(Some(FieldElement::TWO)); + let simulate_flag = vec![SimulationFlagForEstimateFee::SkipValidate]; + let deoxys_estimates = deoxys .estimate_fee( &vec![ok_deoxys_invoke, ok_deoxys_invoke_1, ok_deoxys_invoke_2], - SimulationFlagForEstimateFee::SkipValidate, + simulate_flag.clone(), block_number, ) .await @@ -109,7 +113,7 @@ async fn works_ok(clients: HashMap>) { ok_pathfinder_invoke_1, ok_pathfinder_invoke_2, ], - SimulationFlagForEstimateFee::SkipValidate, + simulate_flag.clone(), block_number, ) .await diff --git a/unit_tests/tests/test_get_transaction_receipt.rs b/unit_tests/tests/test_get_transaction_receipt.rs index f03cb63..e16cec2 100644 --- a/unit_tests/tests/test_get_transaction_receipt.rs +++ b/unit_tests/tests/test_get_transaction_receipt.rs @@ -53,8 +53,6 @@ async fn work_with_hash( .await .unwrap(); - println!("✅ {:?}", response_deoxys); - println!("✅ {:?}", response_pathfinder); assert_eq!(response_deoxys, response_pathfinder); } diff --git a/unit_tests/tests/test_simulate_transaction.rs b/unit_tests/tests/test_simulate_transaction.rs index b2151ca..56a808e 100644 --- a/unit_tests/tests/test_simulate_transaction.rs +++ b/unit_tests/tests/test_simulate_transaction.rs @@ -4,8 +4,8 @@ mod common; use common::*; use starknet_core::types::{ - BlockId, BlockTag, BroadcastedInvokeTransaction, BroadcastedTransaction, ContractErrorData, - FieldElement, SimulationFlag, StarknetError, + BlockId, BlockTag, BroadcastedInvokeTransaction, BroadcastedInvokeTransactionV1, + BroadcastedTransaction, ContractErrorData, FieldElement, SimulationFlag, StarknetError, }; use starknet_core::utils::get_selector_from_name; use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; @@ -48,19 +48,21 @@ use std::convert::From; #[rstest] #[tokio::test] async fn fail_non_existing_block(deoxys: JsonRpcClient) { - let ok_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::ZERO, - signature: vec![], - nonce: FieldElement::ZERO, - sender_address: FieldElement::from_hex_be(ACCOUNT_CONTRACT).unwrap(), - calldata: vec![ - FieldElement::from_hex_be(TEST_CONTRACT_ADDRESS).unwrap(), - get_selector_from_name("sqrt").unwrap(), - FieldElement::from_hex_be("1").unwrap(), - FieldElement::from(81u8), - ], - is_query: false, - }); + let ok_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::ZERO, + signature: vec![], + nonce: FieldElement::ZERO, + sender_address: FieldElement::from_hex_be(ACCOUNT_CONTRACT).unwrap(), + calldata: vec![ + FieldElement::from_hex_be(TEST_CONTRACT_ADDRESS).unwrap(), + get_selector_from_name("sqrt").unwrap(), + FieldElement::from_hex_be("1").unwrap(), + FieldElement::from(81u8), + ], + is_query: false, + }, + )); let response_deoxys = deoxys .simulate_transactions( @@ -88,35 +90,37 @@ async fn fail_non_existing_block(deoxys: JsonRpcClient) { #[rstest] #[tokio::test] async fn fail_max_fee_too_big(deoxys: JsonRpcClient) { - let max_fee_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0xffffffffffffffffff").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", - ) - .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", + let max_fee_invoke_transaction = BroadcastedTransaction::Invoke( + BroadcastedInvokeTransaction::V1(BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0xffffffffffffffffff").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }), + ); let response = deoxys .simulate_transactions( @@ -141,35 +145,37 @@ async fn fail_max_fee_too_big(deoxys: JsonRpcClient) { #[rstest] #[tokio::test] async fn fail_max_fee_too_low(deoxys: JsonRpcClient) { - let max_fee_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0xf").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", + let max_fee_invoke_transaction = BroadcastedTransaction::Invoke( + BroadcastedInvokeTransaction::V1(BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0xf").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", - ) - .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }), + ); let response = deoxys .simulate_transactions( @@ -194,65 +200,69 @@ async fn fail_max_fee_too_low(deoxys: JsonRpcClient) { #[rstest] #[tokio::test] async fn fail_if_one_txn_cannot_be_executed(deoxys: JsonRpcClient) { - let ok_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", + let ok_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }, + )); + + let bad_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x0626236383637613031643464656463376662666332333632613332313635373", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x0386138666231633730323431643031326132323734393763346334353632343", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x26").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x06b0f22f1c1f96146543d4f506ce3b6f76bcf6f154ce1db4ea8e61be341f4026", ) .unwrap(), - ], - is_query: false, - }); - - let bad_invoke_transaction = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x0626236383637613031643464656463376662666332333632613332313635373", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x0386138666231633730323431643031326132323734393763346334353632343", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x26").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x06b0f22f1c1f96146543d4f506ce3b6f76bcf6f154ce1db4ea8e61be341f4026", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x28ad8723f66b38cab4be89d082dc21860a67e318b69e0b3adc3fc09c5bb32fa", - ) - .unwrap(), - FieldElement::from_hex_be( - "0xecfd5662af5fbcbb005e88a74bd1d7f0e5d78a4d0a278fa1744114fdd14405", - ) - .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x28ad8723f66b38cab4be89d082dc21860a67e318b69e0b3adc3fc09c5bb32fa", + ) + .unwrap(), + FieldElement::from_hex_be( + "0xecfd5662af5fbcbb005e88a74bd1d7f0e5d78a4d0a278fa1744114fdd14405", + ) + .unwrap(), + ], + is_query: false, + }, + )); let response_deoxys = deoxys .simulate_transactions( @@ -289,35 +299,37 @@ async fn works_ok_on_no_validate( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0x00").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", - ) - .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", + let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0x00").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }, + )); let tx_next = tx.clone(); @@ -352,26 +364,28 @@ async fn works_ok_on_validate_without_signature_with_skip_validate( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), - signature: vec![], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", - ) - .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", + let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0xffffffffffff").unwrap(), + signature: vec![], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }, + )); let tx_next = tx.clone(); @@ -404,35 +418,37 @@ async fn works_ok_without_max_fee_with_skip_fee_charge( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), - signature: vec![ - FieldElement::from_hex_be( - "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", - ) - .expect("REASON"), - FieldElement::from_hex_be( - "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", - ) - .expect("REASON"), - ], - nonce: FieldElement::from_hex_be("0x22").unwrap(), - sender_address: FieldElement::from_hex_be( - "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", - ) - .unwrap(), - calldata: vec![ - FieldElement::from_hex_be( - "0x0333366346336346435623165626564653266623531386661366635396565623", - ) - .unwrap(), - FieldElement::from_hex_be( - "0x0653535393433653264616163313937353164313735393562666532383464356", + let tx = BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::from_hex_be("0x0ffffffff").unwrap(), + signature: vec![ + FieldElement::from_hex_be( + "0x5687164368262e1885f904c31bfe55362d91b9a5195d220d5d59aa3c8286349", + ) + .expect("REASON"), + FieldElement::from_hex_be( + "0x2bf8dd834492afe810152fe45083b8c768d62556f772885624ccbd52c6b80d7", + ) + .expect("REASON"), + ], + nonce: FieldElement::from_hex_be("0x22").unwrap(), + sender_address: FieldElement::from_hex_be( + "0x019f57133d6a46990231a58a8f45be87405b4494161bf9ac7b25bd14de6e4d40", ) .unwrap(), - ], - is_query: false, - }); + calldata: vec![ + FieldElement::from_hex_be( + "0x0333366346336346435623165626564653266623531386661366635396565623", + ) + .unwrap(), + FieldElement::from_hex_be( + "0x0653535393433653264616163313937353164313735393562666532383464356", + ) + .unwrap(), + ], + is_query: false, + }, + )); let tx_next = tx.clone();