Skip to content

Commit

Permalink
test(starknet_client): integration test with the starknet GW (#1258)
Browse files Browse the repository at this point in the history
test(JSON-RPC): integration test with the starknet GW
  • Loading branch information
TzahiTaub authored Oct 16, 2023
1 parent 229ee42 commit bf586b2
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- run: >
cargo test -r --test '*' -- --include-ignored;
cargo test -r --test '*' -- --include-ignored --skip test_gw_integration_testnet;
cargo run -r -p papyrus_node --bin central_source_integration_test
rustfmt:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/nightly-tests-call.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: nightly-tests-call

on:
workflow_call:
inputs:
os:
required: true
type: string
secrets:
INTEGRATION_TESTNET_NODE_URL:
required: true
INTEGRATION_TESTNET_SENDER_PRIVATE_KEY:
required: true

jobs:
GW-integration-test-call:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
# Workflow steps exit upon failure of a subcommand (running `set -e` implicitly before the
# run. As we want to keep running this step after a test failure we can either start with
# `set +e` to suppress all errors, or, as done below, append `|| retVal=$?` to the command
# which makes it successful while storing the potential erroneous code.
- run: >
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 papyrus_rpc test_gw_integration_testnet
-- --ignored || retVal=$?;
if [ $retVal -ne 0 ]; then
echo "Integration test failed with exit code $retVal";
fi;
exit $retVal
28 changes: 28 additions & 0 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: nightly-tests
# We run gateway_integration_test at different times, to avoid a nonce race between parallel runs.
on:
schedule:
- cron: '30 0 * * *' # Uses ubuntu runner.
- cron: '30 3 * * *' # Uses macos runner.
workflow_dispatch: # Uses ubuntu runner.

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 * * *'


143 changes: 135 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ serde_yaml = "0.9.16"
sha3 = "0.10.8"
simple_logger = "4.0.0"
starknet_api = "0.5.0-rc1"
starknet-core = "0.6.0"
starknet-crypto = "0.5.1"
strum = "0.25.0"
strum_macros = "0.25.2"
Expand Down
1 change: 1 addition & 0 deletions crates/papyrus_rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/papyrus_rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ use validator::Validate;
use crate::api::get_methods_from_supported_apis;
use crate::middleware::{deny_requests_with_unsupported_path, proxy_rpc_request};
use crate::syncing_state::get_last_synced_block;
pub use crate::v0_4_0::transaction::{InvokeTransaction, InvokeTransactionV1};
pub use crate::v0_4_0::write_api_result::AddInvokeOkResult;

/// Maximum size of a supported transaction body - 10MB.
pub const SERVER_MAX_BODY_SIZE: u32 = 10 * 1024 * 1024;
Expand Down
Loading

0 comments on commit bf586b2

Please sign in to comment.