-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/erc721-enumerable
- Loading branch information
Showing
31 changed files
with
848 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mydir=$(dirname "$0") | ||
cd "$mydir" || exit | ||
cd ../.. | ||
|
||
# Check contract wasm binary by crate name | ||
check_wasm () { | ||
local CONTRACT_CRATE_NAME=$1 | ||
local CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME//-/_}.wasm" | ||
|
||
echo | ||
echo "Checking contract $CONTRACT_CRATE_NAME" | ||
cargo stylus check --wasm-file-path ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME" | ||
} | ||
|
||
# Retrieve all alphanumeric contract's crate names in `./examples` directory. | ||
get_example_crate_names () { | ||
# shellcheck disable=SC2038 | ||
# NOTE: optimistically relying on the 'name = ' string at Cargo.toml file | ||
find ./examples -type f -name "Cargo.toml" | xargs grep 'name = ' | grep -oE '".*"' | tr -d "'\"" | ||
} | ||
|
||
NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly} | ||
|
||
cargo +"$NIGHTLY_TOOLCHAIN" build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort | ||
|
||
for CRATE_NAME in $(get_example_crate_names) | ||
do | ||
check_wasm "$CRATE_NAME" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: check-wasm | ||
# This workflow checks that the compiled wasm binary of every example contract | ||
# can be deployed to Arbitrum Stylus. | ||
# | ||
# NOTE: This is using version `0.2.1` of `cargo-stylus`, which we will need | ||
# to update once `nitro-testnode` gets updated. | ||
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: | ||
check-wasm: | ||
name: check WASM binary | ||
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: run wasm check | ||
run: | | ||
export NIGHTLY_TOOLCHAIN=${{steps.toolchain.outputs.name}} | ||
./.github/scripts/check-wasm.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ name: e2e-tests | |
# | ||
# 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. | ||
# - The test suite runs | ||
# Test contract deployments and test user funding happen per test. | ||
permissions: | ||
contents: read | ||
on: | ||
|
@@ -53,20 +52,7 @@ jobs: | |
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 | ||
run: ./e2e-tests/nitro-testnode.sh -d -i | ||
|
||
- name: run integration tests | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
docs/build/ | ||
|
||
**/.DS_Store | ||
|
||
/e2e-tests/nitro-testnode |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
fn main() { | ||
set_env("TARGET_DIR", &get_target_dir()); | ||
set_env("RPC_URL", "http://localhost:8547"); | ||
set_env( | ||
"TEST_NITRO_NODE_PATH", | ||
Path::new(&load_env_var("CARGO_MANIFEST_DIR")) | ||
.join("nitro-testnode") | ||
.to_str() | ||
.expect("set env var TEST_NITRO_NODE_PATH"), | ||
); | ||
} | ||
|
||
fn set_env(var_name: &str, value: &str) { | ||
println!("cargo:rustc-env={}={}", var_name, value); | ||
} | ||
|
||
fn load_env_var(var_name: &str) -> String { | ||
std::env::var(var_name) | ||
.unwrap_or_else(|_| panic!("failed to load {} env var", var_name)) | ||
} | ||
|
||
fn get_target_dir() -> String { | ||
// should be smth like | ||
// ./rust-contracts-stylus/target/debug/build/e2e-tests-b008947425bb8267/out | ||
let out_dir = load_env_var("OUT_DIR"); | ||
let target_dir = Path::new(&out_dir).join("../../../../"); | ||
target_dir.to_str().expect("target dir").to_string() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
MYDIR=$(realpath "$(dirname "$0")") | ||
cd "$MYDIR" || exit | ||
|
||
HAS_INIT=false | ||
HAS_DETACH=false | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
case "$1" in | ||
-i|--init) | ||
HAS_INIT=true | ||
shift | ||
;; | ||
-d|--detach) | ||
HAS_DETACH=true | ||
shift | ||
;; | ||
-down|--shutdown) | ||
docker container stop "$(docker container ls -q --filter name=nitro-testnode)" | ||
exit 0 | ||
;; | ||
*) | ||
echo "OPTIONS:" | ||
echo "-i|--init: clone repo and init nitro test node" | ||
echo "-d|--detach: setup nitro test node in detached mode" | ||
echo "-down|--shutdown: shutdown nitro test node docker containers" | ||
exit 0 | ||
;; | ||
esac | ||
done | ||
|
||
TEST_NODE_DIR="$MYDIR/nitro-testnode" | ||
if [ ! -d "$TEST_NODE_DIR" ]; then | ||
HAS_INIT=true | ||
fi | ||
|
||
if $HAS_INIT | ||
then | ||
cd "$MYDIR" || exit | ||
# clone nitro test node repo | ||
git clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git | ||
cd ./nitro-testnode || exit | ||
git checkout 1886f4b89f5c20fd5b0c2cf3d08a009ee73e45ca || exit | ||
|
||
# setup nitro test node | ||
./test-node.bash --no-run --init --no-tokenbridge || exit | ||
fi | ||
|
||
|
||
cd "$TEST_NODE_DIR" || exit | ||
if $HAS_DETACH | ||
then | ||
./test-node.bash --detach | ||
else | ||
./test-node.bash | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
use ethers::prelude::*; | ||
|
||
use crate::context::*; | ||
use e2e::prelude::*; | ||
|
||
abigen!( | ||
Erc20Token, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
use ethers::prelude::*; | ||
|
||
use crate::context::*; | ||
use e2e::prelude::*; | ||
|
||
abigen!( | ||
Erc721Token, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod erc20; | ||
pub mod erc721; |
Oops, something went wrong.