From 41e534c916eedbd6f28eb81ed54cc6fa907a5c14 Mon Sep 17 00:00:00 2001 From: Tzahi Taub Date: Thu, 12 Oct 2023 02:10:12 +0300 Subject: [PATCH] test(JSON-RPC): integration test with the starknet GW Move test from starknet_client to papyrus_rpc crate to avoid circular dependencies. --- .github/workflows/nightly-tests-call.yml | 2 +- .github/workflows/nightly-tests.yml | 9 +++++++++ Cargo.lock | 4 +--- crates/papyrus_rpc/Cargo.toml | 1 + .../tests/gateway_integration_test.rs | 14 +++++--------- crates/starknet_client/Cargo.toml | 4 ---- 6 files changed, 17 insertions(+), 17 deletions(-) rename crates/{starknet_client => papyrus_rpc}/tests/gateway_integration_test.rs (93%) diff --git a/.github/workflows/nightly-tests-call.yml b/.github/workflows/nightly-tests-call.yml index 9fbaf85fc4..2e9f896058 100644 --- a/.github/workflows/nightly-tests-call.yml +++ b/.github/workflows/nightly-tests-call.yml @@ -24,7 +24,7 @@ jobs: sudo apt update; sudo apt -y install libclang-dev; INTEGRATION_TESTNET_NODE_URL=${{ secrets.INTEGRATION_TESTNET_NODE_URL }} SENDER_PRIVATE_KEY=${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} - cargo test --test gateway_integration_test -p starknet_client test_gw_integration_testnet + cargo test --test gateway_integration_test -p papyrus_rpc test_gw_integration_testnet -- --ignored || retVal=$?; if [ $retVal -ne 0 ]; then echo "Integration test failed with exit code $retVal"; diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index 9f70b33caa..d2cf5a5076 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -5,18 +5,27 @@ on: - cron: '30 0 * * *' # Uses ubuntu runner. - cron: '30 3 * * *' # Uses macos runner. workflow_dispatch: # Uses ubuntu runner. + push: + branches: + - tzahi/gw_integration_test_basic jobs: GW-integration-test-ubuntu: uses: ./.github/workflows/nightly-tests-call.yml with: os: ubuntu-latest + secrets: + INTEGRATION_TESTNET_NODE_URL: ${{ secrets.INTEGRATION_TESTNET_NODE_URL }} + INTEGRATION_TESTNET_SENDER_PRIVATE_KEY: ${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} if: github.event.schedule != '30 3 * * *' GW-integration-test-macos: uses: ./.github/workflows/nightly-tests-call.yml with: os: macos-latest + secrets: + INTEGRATION_TESTNET_NODE_URL: ${{ secrets.INTEGRATION_TESTNET_NODE_URL }} + INTEGRATION_TESTNET_SENDER_PRIVATE_KEY: ${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} if: github.event.schedule == '30 3 * * *' diff --git a/Cargo.lock b/Cargo.lock index 3f9db73b24..cab7f40753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4550,6 +4550,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "starknet-core", "starknet_api", "starknet_client", "strum 0.25.0", @@ -6157,19 +6158,16 @@ dependencies = [ "enum-iterator", "http", "indexmap 1.9.3", - "jsonrpsee", "mockall", "mockito", "os_info", "papyrus_config", - "papyrus_rpc", "pretty_assertions", "rand", "rand_chacha", "reqwest", "serde", "serde_json", - "starknet-core", "starknet_api", "test_utils", "thiserror", diff --git a/crates/papyrus_rpc/Cargo.toml b/crates/papyrus_rpc/Cargo.toml index 012f30e37d..26824ff695 100644 --- a/crates/papyrus_rpc/Cargo.toml +++ b/crates/papyrus_rpc/Cargo.toml @@ -57,6 +57,7 @@ reqwest.workspace = true test_utils = { path = "../test_utils" } starknet_api = { workspace = true, features = ["testing"] } starknet_client = { path = "../starknet_client", features = ["testing"] } +starknet-core.workspace = true strum.workspace = true strum_macros.workspace = true indexmap = { workspace = true, features = ["serde"] } diff --git a/crates/starknet_client/tests/gateway_integration_test.rs b/crates/papyrus_rpc/tests/gateway_integration_test.rs similarity index 93% rename from crates/starknet_client/tests/gateway_integration_test.rs rename to crates/papyrus_rpc/tests/gateway_integration_test.rs index 7dd2faab35..1a293ef6d0 100644 --- a/crates/starknet_client/tests/gateway_integration_test.rs +++ b/crates/papyrus_rpc/tests/gateway_integration_test.rs @@ -4,11 +4,7 @@ use jsonrpsee::core::client::ClientT; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::rpc_params; use papyrus_common::transaction_hash::get_transaction_hash; -use papyrus_rpc::{ - AddInvokeOkResult, - InvokeTransaction as SNRpcInvokeTransaction, - InvokeTransactionV1 as SNRpcInvokeTransactionV1, -}; +use papyrus_rpc::{AddInvokeOkResult, InvokeTransaction, InvokeTransactionV1}; use starknet_api::core::{ChainId, ContractAddress, EntryPointSelector, Nonce, PatriciaKey}; use starknet_api::hash::{StarkFelt, StarkHash}; use starknet_api::transaction::{ @@ -19,7 +15,7 @@ use starknet_api::transaction::{ TransactionVersion, }; use starknet_api::{calldata, contract_address, patricia_key, stark_felt}; -use starknet_client::writer::objects::transaction::InvokeTransaction; +use starknet_client::writer::objects::transaction::InvokeTransaction as SNClientInvokeTransaction; use starknet_core::crypto::ecdsa_sign; use starknet_core::types::FieldElement; @@ -79,7 +75,7 @@ async fn test_gw_integration_testnet() { let receiver_address = contract_address!(USER_B_ADDRESS); // Create an invoke transaction for Eth transfer with a signature placeholder. - let mut invoke_tx = SNRpcInvokeTransactionV1 { + let mut invoke_tx = InvokeTransactionV1 { max_fee: Fee(MAX_FEE), signature: TransactionSignature::default(), nonce, @@ -104,7 +100,7 @@ async fn test_gw_integration_testnet() { // Update the signature. let hash = get_transaction_hash( - &Transaction::Invoke(SNRpcInvokeTransaction::Version1(invoke_tx.clone()).into()), + &Transaction::Invoke(InvokeTransaction::Version1(invoke_tx.clone()).into()), &ChainId("SN_GOERLI".to_string()), ) .unwrap(); @@ -121,7 +117,7 @@ async fn test_gw_integration_testnet() { let invoke_res = client .request::( "starknet_addInvokeTransaction", - rpc_params!(InvokeTransaction::from(invoke_tx)), + rpc_params!(SNClientInvokeTransaction::from(invoke_tx)), ) .await .unwrap(); diff --git a/crates/starknet_client/Cargo.toml b/crates/starknet_client/Cargo.toml index 227e930a88..739bb11ade 100644 --- a/crates/starknet_client/Cargo.toml +++ b/crates/starknet_client/Cargo.toml @@ -42,14 +42,10 @@ url.workspace = true assert.workspace = true assert_matches.workspace = true enum-iterator.workspace = true -jsonrpsee = { workspace = true, features = ["full"] } mockall.workspace = true mockito.workspace = true rand.workspace = true rand_chacha.workspace = true -papyrus_common = { path = "../papyrus_common"} -papyrus_rpc = { path = "../papyrus_rpc"} pretty_assertions.workspace = true starknet_api = { workspace = true, features = ["testing"] } -starknet-core.workspace = true test_utils = { path = "../test_utils" }