diff --git a/Cargo.lock b/Cargo.lock index 3aa44af..d492522 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2157,8 +2157,8 @@ dependencies = [ "starknet-accounts 0.6.1", "starknet-contract 0.6.0", "starknet-core 0.7.2", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-crypto 0.6.1", + "starknet-ff 0.3.5", "starknet-macros 0.1.4", "starknet-providers 0.7.0", "starknet-signers 0.5.0", @@ -2166,17 +2166,17 @@ dependencies = [ [[package]] name = "starknet" -version = "0.8.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.10.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ - "starknet-accounts 0.7.0", - "starknet-contract 0.7.0", - "starknet-core 0.8.0", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-macros 0.1.5", - "starknet-providers 0.8.0", - "starknet-signers 0.6.0", + "starknet-accounts 0.9.0", + "starknet-contract 0.9.0", + "starknet-core 0.10.0", + "starknet-crypto 0.6.2", + "starknet-ff 0.3.7", + "starknet-macros 0.1.7", + "starknet-providers 0.10.0", + "starknet-signers 0.8.0", ] [[package]] @@ -2194,14 +2194,14 @@ dependencies = [ [[package]] name = "starknet-accounts" -version = "0.7.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.9.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "async-trait", "auto_impl", - "starknet-core 0.8.0", - "starknet-providers 0.8.0", - "starknet-signers 0.6.0", + "starknet-core 0.10.0", + "starknet-providers 0.10.0", + "starknet-signers 0.8.0", "thiserror", ] @@ -2221,15 +2221,15 @@ dependencies = [ [[package]] name = "starknet-contract" -version = "0.7.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.9.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "serde", "serde_json", "serde_with", - "starknet-accounts 0.7.0", - "starknet-core 0.8.0", - "starknet-providers 0.8.0", + "starknet-accounts 0.9.0", + "starknet-core 0.10.0", + "starknet-providers 0.10.0", "thiserror", ] @@ -2246,14 +2246,14 @@ dependencies = [ "serde_json_pythonic", "serde_with", "sha3", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-crypto 0.6.1", + "starknet-ff 0.3.5", ] [[package]] name = "starknet-core" -version = "0.8.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.10.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "base64 0.21.6", "flate2", @@ -2263,8 +2263,8 @@ dependencies = [ "serde_json_pythonic", "serde_with", "sha3", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", + "starknet-crypto 0.6.2", + "starknet-ff 0.3.7", ] [[package]] @@ -2280,16 +2280,16 @@ dependencies = [ "num-traits", "rfc6979", "sha2", - "starknet-crypto-codegen 0.3.2 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", - "starknet-curve 0.4.0 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-crypto-codegen 0.3.2", + "starknet-curve 0.4.0", + "starknet-ff 0.3.5", "zeroize", ] [[package]] name = "starknet-crypto" -version = "0.6.1" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.6.2" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "crypto-bigint", "hex", @@ -2299,9 +2299,9 @@ dependencies = [ "num-traits", "rfc6979", "sha2", - "starknet-crypto-codegen 0.3.2 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-curve 0.4.0 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", + "starknet-crypto-codegen 0.3.3", + "starknet-curve 0.4.2", + "starknet-ff 0.3.7", "zeroize", ] @@ -2310,18 +2310,18 @@ name = "starknet-crypto-codegen" version = "0.3.2" source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36#64ebc364c0c346e81b715c5b4a3b32ef37b055c8" dependencies = [ - "starknet-curve 0.4.0 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-curve 0.4.0", + "starknet-ff 0.3.5", "syn 2.0.48", ] [[package]] name = "starknet-crypto-codegen" -version = "0.3.2" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.3.3" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ - "starknet-curve 0.4.0 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", + "starknet-curve 0.4.2", + "starknet-ff 0.3.7", "syn 2.0.48", ] @@ -2330,15 +2330,15 @@ name = "starknet-curve" version = "0.4.0" source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36#64ebc364c0c346e81b715c5b4a3b32ef37b055c8" dependencies = [ - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-ff 0.3.5", ] [[package]] name = "starknet-curve" -version = "0.4.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.4.2" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ - "starknet-ff 0.3.5 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", + "starknet-ff 0.3.7", ] [[package]] @@ -2356,8 +2356,8 @@ dependencies = [ [[package]] name = "starknet-ff" -version = "0.3.5" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.3.7" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "ark-ff", "bigdecimal", @@ -2378,10 +2378,10 @@ dependencies = [ [[package]] name = "starknet-macros" -version = "0.1.5" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.1.7" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ - "starknet-core 0.8.0", + "starknet-core 0.10.0", "syn 2.0.48", ] @@ -2406,8 +2406,8 @@ dependencies = [ [[package]] name = "starknet-providers" -version = "0.8.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.10.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "async-trait", "auto_impl", @@ -2418,7 +2418,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet-core 0.8.0", + "starknet-core 0.10.0", "thiserror", "url", ] @@ -2434,22 +2434,22 @@ dependencies = [ "eth-keystore", "rand", "starknet-core 0.7.2", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=64ebc36)", + "starknet-crypto 0.6.1", "thiserror", ] [[package]] name = "starknet-signers" -version = "0.6.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803#96c6803118773d9fd1d74fcf1465763f11a080a1" +version = "0.8.0" +source = "git+https://github.com/kasarlabs/starknet-rs.git?branch=fork#d5af8dee02e36706ef06574db580f6773e23d37d" dependencies = [ "async-trait", "auto_impl", "crypto-bigint", "eth-keystore", "rand", - "starknet-core 0.8.0", - "starknet-crypto 0.6.1 (git+https://github.com/xJonathanLEI/starknet-rs.git?rev=96c6803)", + "starknet-core 0.10.0", + "starknet-crypto 0.6.2", "thiserror", ] @@ -2815,11 +2815,11 @@ dependencies = [ "rand", "rstest", "serde_json", - "starknet 0.8.0", - "starknet-accounts 0.7.0", - "starknet-core 0.8.0", - "starknet-providers 0.8.0", - "starknet-signers 0.6.0", + "starknet 0.10.0", + "starknet-accounts 0.9.0", + "starknet-core 0.10.0", + "starknet-providers 0.10.0", + "starknet-signers 0.8.0", "tokio", "url", ] diff --git a/macro_utils/Cargo.toml b/macro_utils/Cargo.toml index 72af1f9..9b4900b 100644 --- a/macro_utils/Cargo.toml +++ b/macro_utils/Cargo.toml @@ -16,4 +16,4 @@ url = "2.5.0" syn = "2.0.48" quote = "1.0.35" tokio = { version = "1", features = ["full"] } -lazy_static = "1.4.0" +lazy_static = "1.4.0" \ No newline at end of file diff --git a/unit_tests/Cargo.toml b/unit_tests/Cargo.toml index 32911a9..4775814 100644 --- a/unit_tests/Cargo.toml +++ b/unit_tests/Cargo.toml @@ -10,11 +10,11 @@ anyhow = "1.0.79" rstest = "0.18.2" tokio = { version = "1", features = ["full"] } url = "2.5.0" -starknet = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "96c6803", default-features = false } -starknet-core = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "96c6803", default-features = false } -starknet-providers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "96c6803", default-features = false } -starknet-accounts = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "96c6803", default-features = false } -starknet-signers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "96c6803", default-features = false } +starknet = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork", default-features = false } +starknet-core = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork", default-features = false } +starknet-providers = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork", default-features = false } +starknet-accounts = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork", default-features = false } +starknet-signers = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork", default-features = false } env_logger = "0.10.1" macro_utils = { path = "../macro_utils/" } rand = "0.8.5" diff --git a/unit_tests/src/constants.rs b/unit_tests/src/constants.rs index 1b4f336..5d9d926 100644 --- a/unit_tests/src/constants.rs +++ b/unit_tests/src/constants.rs @@ -162,4 +162,4 @@ pub const ERR_PATHFINDER: &str = "Error waiting for response from Pathfinder cli pub const SPEC_0_5_1: &str = "0.5.1"; pub const SPEC_0_6_0: &str = "0.6.0"; -pub const SPEC_0_7_0: &str = "0.7.0"; \ No newline at end of file +pub const SPEC_0_7_0: &str = "0.7.0"; diff --git a/unit_tests/src/lib.rs b/unit_tests/src/lib.rs index 9396d4c..6e2aae0 100644 --- a/unit_tests/src/lib.rs +++ b/unit_tests/src/lib.rs @@ -3,8 +3,9 @@ use constants::*; use starknet_accounts::{Account, Call, ConnectedAccount, Execution, SingleOwnerAccount}; use starknet_core::chain_id; +use starknet_core::types::BroadcastedInvokeTransaction; use starknet_core::{ - types::{BroadcastedInvokeTransaction, BroadcastedTransaction, FieldElement}, + types::{BroadcastedInvokeTransactionV1, BroadcastedTransaction, FieldElement}, utils::get_selector_from_name, }; use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient}; @@ -22,19 +23,21 @@ pub struct OkTransactionFactory; impl TransactionFactory for OkTransactionFactory { fn build(nonce: Option) -> BroadcastedTransaction { - BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { - max_fee: FieldElement::ZERO, - signature: vec![], - nonce: nonce.unwrap_or(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: true, - }) + BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1( + BroadcastedInvokeTransactionV1 { + max_fee: FieldElement::ZERO, + signature: vec![], + nonce: nonce.unwrap_or(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: true, + }, + )) } } @@ -42,14 +45,15 @@ pub struct BadTransactionFactory; impl TransactionFactory for BadTransactionFactory { fn build(_: Option) -> BroadcastedTransaction { - BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { + let transaction_v1 = BroadcastedInvokeTransactionV1 { max_fee: FieldElement::default(), nonce: FieldElement::ZERO, sender_address: FieldElement::default(), signature: vec![], calldata: vec![FieldElement::from_hex_be("0x0").unwrap()], is_query: true, - }) + }; + BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1(transaction_v1)) } } @@ -57,7 +61,7 @@ pub struct MaxFeeTransactionFactory; impl TransactionFactory for MaxFeeTransactionFactory { fn build(_: Option) -> BroadcastedTransaction { - BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction { + let transaction_v1 = BroadcastedInvokeTransactionV1 { max_fee: FieldElement::from_hex_be("0x100000000000000000000000000000000").unwrap(), signature: vec![], nonce: FieldElement::ZERO, @@ -72,7 +76,8 @@ impl TransactionFactory for MaxFeeTransactionFactory { FieldElement::from(81u8), ], is_query: false, - }) + }; + BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1(transaction_v1)) } } @@ -98,7 +103,7 @@ pub fn build_single_owner_account<'a>( rpc, signer, account_address, - chain_id::TESTNET, + chain_id::SEPOLIA, execution_encoding, ) } @@ -111,7 +116,7 @@ pub trait PrepareInvoke { nonce: FieldElement, max_fee: FieldElement, query_only: bool, - ) -> BroadcastedInvokeTransaction; + ) -> BroadcastedInvokeTransactionV1; } impl PrepareInvoke for SingleOwnerAccount<&JsonRpcClient, LocalWallet> { @@ -121,7 +126,7 @@ impl PrepareInvoke for SingleOwnerAccount<&JsonRpcClient, LocalWa nonce: FieldElement, max_fee: FieldElement, query_only: bool, - ) -> BroadcastedInvokeTransaction + ) -> BroadcastedInvokeTransactionV1 where Self: Account + ConnectedAccount, { @@ -130,10 +135,16 @@ impl PrepareInvoke for SingleOwnerAccount<&JsonRpcClient, LocalWa .max_fee(max_fee) .prepared() .unwrap(); - prepared_execution + + let invoke_request = prepared_execution .get_invoke_request(query_only) .await - .unwrap() + .unwrap(); + + match invoke_request { + BroadcastedInvokeTransaction::V1(invoke_transaction) => invoke_transaction, + BroadcastedInvokeTransaction::V3(_) => panic!("V3 transactions are not supported yet"), + } } } diff --git a/unit_tests/tests/common.rs b/unit_tests/tests/common.rs index d4df226..ebed895 100644 --- a/unit_tests/tests/common.rs +++ b/unit_tests/tests/common.rs @@ -1,6 +1,7 @@ -use starknet_core::types::BlockId; use starknet_core::types::StarknetError; +use starknet_core::types::{BlockId, BlockTag}; use starknet_providers::ProviderError; +use std::env; /* Common imports used throughout all unit tests */ #[allow(unused_imports)] @@ -35,14 +36,18 @@ pub fn checking_error_format(response: &ProviderError, expected_error: StarknetE } } -pub fn get_max_block_value() -> 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 + +// If no env variable, by default we use block 100000 +pub fn get_block_setting() -> BlockId { + let block_id = env::var("BLOCK_SETTING").unwrap_or_else(|_| "100000".into()); + match block_id.as_ref() { + "latest" => BlockId::Tag(BlockTag::Latest), + "pending" => BlockId::Tag(BlockTag::Pending), + _ => match block_id.parse::() { + Ok(num) => BlockId::Number(num), + Err(_) => BlockId::Number(100000), + }, + } +} diff --git a/unit_tests/tests/test_call.rs b/unit_tests/tests/test_call.rs index 61390f5..08f6048 100644 --- a/unit_tests/tests/test_call.rs +++ b/unit_tests/tests/test_call.rs @@ -23,7 +23,7 @@ use starknet_providers::{ #[rstest] #[tokio::test] async fn fail_non_existing_block(clients: HashMap>) { - let deoxys = &clients[JUNO]; + let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; let response_deoxys = deoxys @@ -258,13 +258,11 @@ async fn fail_too_many_call_data(clients: HashMap entry_point_selector: get_selector_from_name("name").unwrap(), calldata: vec![], }, - get_max_block_value() + BlockId::Tag(BlockTag::Latest), ) .await .expect("Error waiting for response from Deoxys node"); @@ -316,16 +314,13 @@ async fn work_correct_call(clients: HashMap entry_point_selector: get_selector_from_name("name").unwrap(), calldata: vec![], }, - get_max_block_value() + BlockId::Tag(BlockTag::Latest), ) .await .expect("Error waiting for response from Pathfinder node"); let response_expected = short_string!("Ether"); - println!("{:?}", response_deoxys); - println!("{:?}", response_pathfinder); - assert_eq!(response_deoxys, vec![response_expected]); assert_eq!(response_deoxys, response_pathfinder); } @@ -342,7 +337,7 @@ async fn work_correct_call_with_args(clients: HashMap) { - 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 206617b..ccfc8aa 100644 --- a/unit_tests/tests/test_estimate_fee.rs +++ b/unit_tests/tests/test_estimate_fee.rs @@ -3,7 +3,9 @@ mod common; use common::*; -use starknet_core::types::{BlockId, BlockTag, FieldElement, StarknetError}; +use starknet_core::types::{ + BlockId, BlockTag, FieldElement, SimulationFlagForEstimateFee, StarknetError, +}; use starknet_providers::{ jsonrpc::{HttpTransport, JsonRpcClient, JsonRpcError}, Provider, @@ -11,6 +13,7 @@ use starknet_providers::{ use std::collections::HashMap; use unit_tests::{BadTransactionFactory, OkTransactionFactory, TransactionFactory}; +//TODO(Tbelleng : Add Simulation Flag to params) #[rstest] #[tokio::test] #[ignore = "Fix failing unwrap due to empty constant"] @@ -18,10 +21,12 @@ async fn fail_non_existing_block(clients: HashMap>) { let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let ok_deoxys_invoke = OkTransactionFactory::build(Some(FieldElement::ZERO)); let ok_deoxys_invoke_1 = OkTransactionFactory::build(Some(FieldElement::ONE)); @@ -88,9 +95,12 @@ async fn works_ok(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], + simulate_flag.clone(), block_number, ) .await @@ -103,6 +113,7 @@ async fn works_ok(clients: HashMap>) { ok_pathfinder_invoke_1, ok_pathfinder_invoke_2, ], + simulate_flag.clone(), block_number, ) .await diff --git a/unit_tests/tests/test_estimate_message_fee.rs b/unit_tests/tests/test_estimate_message_fee.rs index 8bd9800..8b2bad6 100644 --- a/unit_tests/tests/test_estimate_message_fee.rs +++ b/unit_tests/tests/test_estimate_message_fee.rs @@ -165,7 +165,7 @@ async fn estimate_message_fee_works_ok( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let contract_address = FieldElement::from_hex_be( "0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82", diff --git a/unit_tests/tests/test_get_block_transaction_count.rs b/unit_tests/tests/test_get_block_transaction_count.rs index e43f5c9..f8db248 100644 --- a/unit_tests/tests/test_get_block_transaction_count.rs +++ b/unit_tests/tests/test_get_block_transaction_count.rs @@ -42,6 +42,7 @@ async fn fail_non_existing_block(clients: HashMap>) { let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; @@ -140,10 +141,6 @@ async fn work_with_block_100_000_hash(clients: HashMap, pathfinder: JsonRpcClient, - block_number: u64, + _block_number: u64, ) { - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let response_deoxys = deoxys .get_block_with_tx_hashes(block_number) @@ -160,9 +160,6 @@ async fn work_with_block_3800( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 3800 { - return; - } work_with_block(deoxys, pathfinder, 3000).await; } @@ -173,9 +170,6 @@ async fn work_with_block_5066( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 5066 { - return; - } work_with_block(deoxys, pathfinder, 5066).await; } @@ -186,9 +180,6 @@ async fn work_with_block_1500( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 1500 { - return; - } work_with_block(deoxys, pathfinder, 1500).await; } diff --git a/unit_tests/tests/test_get_block_with_txs.rs b/unit_tests/tests/test_get_block_with_txs.rs index 2498e41..7711835 100644 --- a/unit_tests/tests/test_get_block_with_txs.rs +++ b/unit_tests/tests/test_get_block_with_txs.rs @@ -47,7 +47,7 @@ async fn work_with_latest_block(clients: HashMap, block_number: u64, ) { - let block_number = get_max_block_value(); - let response_deoxys = deoxys - .get_block_with_txs(block_number) + .get_block_with_txs(BlockId::Number(block_number)) .await .expect("Error waiting for response from Deoxys node"); let response_pathfinder = pathfinder - .get_block_with_txs(block_number) + .get_block_with_txs(BlockId::Number(block_number)) .await .expect("Error waiting for response from Pathfinder node"); @@ -126,9 +124,6 @@ async fn work_with_block_100_000( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 100_000 { - return; - } work_with_block(deoxys, pathfinder, 100_000).await; } @@ -137,9 +132,6 @@ async fn work_with_block_100_000( async fn work_with_block_one_hundred_thousand_hash( clients: HashMap>, ) { - if *MAX_BLOCK < 100_000 { - return; - } let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; @@ -170,9 +162,6 @@ async fn work_with_block_3800( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 3800 { - return; - } work_with_block(deoxys, pathfinder, 3800).await; } @@ -183,9 +172,6 @@ async fn work_with_block_5066( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 5066 { - return; - } work_with_block(deoxys, pathfinder, 5066).await; } /// block 1466-2242 mismatch block_hash @@ -195,9 +181,6 @@ async fn work_with_block_1500( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 1500 { - return; - } work_with_block(deoxys, pathfinder, 1500).await; } diff --git a/unit_tests/tests/test_get_class_at.rs b/unit_tests/tests/test_get_class_at.rs index 5c9342c..91b0c65 100644 --- a/unit_tests/tests/test_get_class_at.rs +++ b/unit_tests/tests/test_get_class_at.rs @@ -88,10 +88,6 @@ async fn work_contract_v0( let deoxys = &clients[DEOXYS]; let pathfinder = &clients[PATHFINDER]; - if *MAX_BLOCK < BLOCK_LEGACY { - return Ok(()); - } - let response_deoxys = deoxys .get_class_at( BlockId::Number(BLOCK_LEGACY), @@ -147,7 +143,7 @@ async fn work_contract_v1( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let response_deoxys = deoxys .get_class_at( diff --git a/unit_tests/tests/test_get_events.rs b/unit_tests/tests/test_get_events.rs index 4b66598..61ac332 100644 --- a/unit_tests/tests/test_get_events.rs +++ b/unit_tests/tests/test_get_events.rs @@ -135,9 +135,6 @@ async fn work_valid_call_no_selector( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 50000 { - return; - } let keys: Vec> = vec![vec![selector!("transaction_executed")]]; let block_nu: u64 = 50000; let block_hash: FieldElement = @@ -173,9 +170,6 @@ async fn work_valid_call_single_selector( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 50000 { - return; - } // event type to retrieve let keys: Vec> = vec![vec![selector!("transaction_executed")]]; let block_nu: u64 = 50000; @@ -212,9 +206,6 @@ async fn work_valid_call_multiple_selector( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 50000 { - return; - } let keys: Vec> = vec![vec![ selector!("transaction_executed"), selector!("account_created"), @@ -295,8 +286,8 @@ async fn deep_check_events( .first() .unwrap() .contains(clone_event.keys.first().unwrap())); - assert_eq!(clone_event.block_hash, block_hash); - assert_eq!(clone_event.block_number, block_nu); + assert_eq!(clone_event.block_hash, Some(block_hash)); + assert_eq!(clone_event.block_number, Some(block_nu)); assert_ne!(clone_event.data.len(), 0); anyhow::Ok(()) diff --git a/unit_tests/tests/test_get_nonce.rs b/unit_tests/tests/test_get_nonce.rs index 8f64edb..29ade41 100644 --- a/unit_tests/tests/test_get_nonce.rs +++ b/unit_tests/tests/test_get_nonce.rs @@ -103,12 +103,9 @@ async fn fail_non_existing_contract(clients: HashMap>) { let deoxys = &clients[DEOXYS]; - if *MAX_BLOCK < 500200 { - //This contract was created at Block 500198 - return; - } + //This contract was created at Block 500198, so need to be synced to this minimum block - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let response_deoxys = deoxys .get_nonce( @@ -132,12 +129,9 @@ async fn work_erc721_contract(clients: HashMap>) { let deoxys = &clients[DEOXYS]; - if *MAX_BLOCK < 500200 { - //This contract was created at Block 500192 - return; - } + //This contract was created at Block 500192, so need to be synced to this minimum block - let block_number = get_max_block_value(); + let block_number = get_block_setting(); let response_deoxys = deoxys .get_nonce( @@ -162,12 +156,9 @@ async fn work_account_contract(clients: HashMap>) { let deoxys = &clients[DEOXYS]; - if *MAX_BLOCK < 5000 { - return; - } - let response_deoxys = deoxys .get_transaction_by_block_id_and_index(BlockId::Number(5000), 389) .await; @@ -84,9 +80,6 @@ async fn work_deploy_invoke(clients: HashMap, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 10 { - return; - } work_with_hash( deoxys, pathfinder, diff --git a/unit_tests/tests/test_get_transaction_receipt.rs b/unit_tests/tests/test_get_transaction_receipt.rs index 8f15f93..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); } @@ -65,9 +63,6 @@ async fn work_with_reverted_transaction_block_200_000( deoxys: JsonRpcClient, pathfinder: JsonRpcClient, ) { - if *MAX_BLOCK < 200_000 { - return; - } work_with_hash( deoxys, pathfinder, diff --git a/unit_tests/tests/test_get_transaction_status.rs b/unit_tests/tests/test_get_transaction_status.rs index be5314a..d843f51 100644 --- a/unit_tests/tests/test_get_transaction_status.rs +++ b/unit_tests/tests/test_get_transaction_status.rs @@ -50,9 +50,6 @@ async fn work_transaction_accepted_on_l1(clients: HashMap) { - 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(); diff --git a/unit_tests/tests/test_trace_block_transactions.rs b/unit_tests/tests/test_trace_block_transactions.rs index 61ce125..44820b7 100644 --- a/unit_tests/tests/test_trace_block_transactions.rs +++ b/unit_tests/tests/test_trace_block_transactions.rs @@ -78,6 +78,8 @@ async fn works_ok_for_random_block( let deoxys_trace = deoxys.trace_block_transactions(block_number).await; let _pathfinder_trace = pathfinder.trace_block_transactions(block_number).await; println!("block choose is: {:?}", block_number); + println!("deoxys_trace: {:?}", deoxys_trace); + println!("pathfinder_trace: {:?}", _pathfinder_trace); assert_matches!(deoxys_trace, _pathfinder_trace); }