diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f664b513..ca72f5e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,27 +31,8 @@ jobs: cargo clippy -- -D clippy::all -D warnings -A clippy::manual_range_contains cargo clippy --tests --benches -- -D clippy::all -D warnings -A clippy::manual_range_contains - cargo-test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - - name: Install PocketIC server - uses: dfinity/pocketic@main - with: - pocket-ic-server-version: "7.0.0" - - - uses: Swatinem/rust-cache@v2 - - - name: Install Protoc - uses: arduino/setup-protoc@v3 - - - name: Cargo test - run: unset CI && cargo test -- --test-threads=2 - - docker-build: - runs-on: ubuntu-latest + reproducible-build: + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@master @@ -65,12 +46,42 @@ jobs: with: name: evm_rpc.wasm.gz path: evm_rpc.wasm.gz + if-no-files-found: error - name: Add summary run: | hash=`sha256sum evm_rpc.wasm.gz` echo "SHA-256 :hash: ${hash}" >> $GITHUB_STEP_SUMMARY + cargo-test: + needs: [ reproducible-build ] + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: evm_rpc.wasm.gz + + - name: Set EVM_RPC_WASM_PATH for load_wasm + run: | + echo "EVM_RPC_WASM_PATH=$GITHUB_WORKSPACE/evm_rpc.wasm.gz" >> "$GITHUB_ENV" + + - name: Install PocketIC server + uses: dfinity/pocketic@main + with: + pocket-ic-server-version: "7.0.0" + + - uses: Swatinem/rust-cache@v2 + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + + - name: Cargo test + run: cargo test -- --test-threads=2 --nocapture + e2e: runs-on: ubuntu-latest steps: @@ -102,6 +113,6 @@ jobs: - name: Run local examples with Foundry run: scripts/examples evm_rpc_local 'Number = 0' - + - name: Check formatting run: cargo fmt --all -- --check diff --git a/tests/tests.rs b/tests/tests.rs index 18f1bd27..4b0a74a0 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -22,7 +22,9 @@ use ic_test_utilities_load_wasm::load_wasm; use maplit::hashmap; use mock::{MockOutcall, MockOutcallBuilder}; use pocket_ic::common::rest::{CanisterHttpMethod, MockCanisterHttpResponse, RawMessageId}; -use pocket_ic::{management_canister::CanisterSettings, PocketIc, WasmResult}; +use pocket_ic::{ + management_canister::CanisterSettings, CallError, ErrorCode, PocketIc, UserError, WasmResult, +}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::json; use std::sync::Arc; @@ -126,18 +128,26 @@ impl EvmRpcSetup { } pub fn upgrade_canister(&self, args: InstallArgs) { - self.env.tick(); - // Avoid `CanisterInstallCodeRateLimited` error - self.env.advance_time(Duration::from_secs(600)); - self.env.tick(); - self.env - .upgrade_canister( + for _ in 0..100 { + self.env.tick(); + // Avoid `CanisterInstallCodeRateLimited` error + self.env.advance_time(Duration::from_secs(600)); + self.env.tick(); + match self.env.upgrade_canister( self.canister_id, evm_rpc_wasm(), Encode!(&args).unwrap(), Some(self.controller), - ) - .expect("Error while upgrading canister"); + ) { + Ok(_) => return, + Err(CallError::UserError(UserError { + code: ErrorCode::CanisterInstallCodeRateLimited, + description: _, + })) => continue, + Err(e) => panic!("Error while upgrading canister: {e:?}"), + } + } + panic!("Failed to upgrade canister after many trials!") } /// Shorthand for deriving an `EvmRpcSetup` with the caller as the canister controller.