Skip to content

Commit

Permalink
feat: local integration tests (#70)
Browse files Browse the repository at this point in the history
Fixes #53

To make tests pass stylus-sdk was reverted to 0.4.3 and associated shim
changes also.
All tests pass serially (in future there is a chance to run them
concurrently).

#### PR Checklist

- [x] Tests
- [x] Documentation

---------

Co-authored-by: Alexander González <[email protected]>
  • Loading branch information
qalisander and alexfertel committed May 23, 2024
1 parent b0fa37d commit d4b0554
Show file tree
Hide file tree
Showing 19 changed files with 4,156 additions and 314 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: cargo doc
run: cargo doc --workspace --no-deps --all-features
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --cfg docsrs
hack:
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: e2e-tests
# This workflow runs our end-to-end tests suite.
#
# It roughly follows these steps:
# - A local `nitro-testnode` gets spun up.
# - Contracts get deployed to the local node.
# - A few addresses get funded.
# - The test suite runs.
permissions:
contents: read
on:
push:
branches: [ main ]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
e2e-tests:
name: integration tests suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}

- name: cache cargo-stylus
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
key: ${{ runner.os }}[email protected]
save-always: true

- name: set up rust
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
target: wasm32-unknown-unknown
components: rust-src
toolchain: nightly-2024-01-01

- name: install cargo-stylus
run: RUSTFLAGS="-C link-args=-rdynamic" cargo install [email protected]

- name: setup nitro node
run: |
# clone nitro test node repo
git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git && cd nitro-testnode
git checkout 1886f4b89f5c20fd5b0c2cf3d08a009ee73e45ca
# setup nitro test node
./test-node.bash --no-run --init --no-tokenbridge
./test-node.bash --detach
# TODO: remove hard coded wallets when user creation will be per test case
# fund Alice's wallet
./test-node.bash script send-l2 --to address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10000
# fund Bob's wallet
./test-node.bash script send-l2 --to address_0xF4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526 --ethamount 10000
- name: run integration tests
run: |
export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}}
./e2e-tests/test.sh
6 changes: 3 additions & 3 deletions .github/workflows/nostd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
contents: read
on:
push:
branches: [main]
branches: [ main ]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -19,7 +19,7 @@ jobs:
name: ${{ matrix.target }}
strategy:
matrix:
target: [wasm32-unknown-unknown]
target: [ wasm32-unknown-unknown ]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -29,4 +29,4 @@ jobs:
- name: rustup target add ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
- name: cargo check
run: cargo check --release --target ${{ matrix.target }} --no-default-features --workspace --all-features
run: cargo check --release --target ${{ matrix.target }} --no-default-features --all-features
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
contents: read
on:
push:
branches: [main]
branches: [ main ]
paths-ignore:
- "**.md"
- "**.adoc"
Expand All @@ -34,7 +34,7 @@ jobs:
matrix:
# Run on stable and beta to ensure that tests won't break on the next
# version of the rust toolchain.
toolchain: [stable, beta]
toolchain: [ stable, beta ]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -50,18 +50,18 @@ jobs:
run: cargo generate-lockfile
# https://twitter.com/jonhoo/status/1571290371124260865
- name: cargo test --locked
run: cargo test --locked --all-features --all-targets --workspace
run: cargo test --locked --all-features --all-targets
# https://github.com/rust-lang/cargo/issues/6669
- name: cargo test --doc
run: cargo test --locked --all-features --doc --workspace
run: cargo test --locked --all-features --doc
os-check:
# Run cargo test on MacOS and Windows.
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / stable
strategy:
fail-fast: false
matrix:
os: [macos-latest]
os: [ macos-latest ]
# Windows fails because of `stylus-proc`.
# os: [macos-latest, windows-latest]
steps:
Expand All @@ -74,7 +74,7 @@ jobs:
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo test
run: cargo test --locked --all-features --all-targets --workspace
run: cargo test --locked --all-features --all-targets
coverage:
# Use llvm-cov to build and collect coverage and outputs in a format that
# is compatible with codecov.io.
Expand Down
Loading

0 comments on commit d4b0554

Please sign in to comment.