Skip to content

Commit

Permalink
e2e setup guide
Browse files Browse the repository at this point in the history
  • Loading branch information
qalisander committed Sep 2, 2024
1 parent d4f57e6 commit 0976b1d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
54 changes: 49 additions & 5 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Use 1-word names for function parameters or variables that have larger scopes:

```rust
pub fn commit(repo: &Repository, sig: &Signature) -> Result<Commit, Error> {
...
...
}
```

Expand Down Expand Up @@ -207,6 +207,47 @@ Make sure all tests are passing with:

$ cargo test --all-features

### Running end-to-end tests

In order to run end-to-end (e2e) tests you need to have a specific nightly toolchain.
"Nightly" is necessary to use optimization compiler flags and have contract wasm small enough to be eligible for
deployment.

Run the following commands to install the necessary toolchain:

```shell
rustup install nightly-2024-01-01
rustup component add rust-src
```

Also, you should have the cargo stylus tool:

```shell
cargo install cargo-stylus
```

Since most of the e2e tests using koba for deploying contracts, you need to install solidity compiler v0.8.21, like
this:

```shell
curl -LO https://github.com/ethereum/solidity/releases/download/v0.8.21/solc-static-linux
sudo mv solc-static-linux /usr/bin/solc
sudo chmod a+x /usr/bin/solc
```

To run e2e tests, you need to have a local nitro test node set up.
Run the following command and wait till script exit successfully:

```shell
./scripts/nitro-testnode.sh -i -d
```

Then you will be able to run e2e tests:

```shell
./scripts/e2e-tests.sh
```

### Checking the docs

If you make documentation changes, you may want to check whether there are any
Expand Down Expand Up @@ -279,12 +320,15 @@ conventions that must be followed.
- Custom errors should be declared following the [EIP-6093] rationale whenever
reasonable. Also, consider the following:

- The domain prefix should be picked in the following order:
1. Use `ERC<number>` if the error is a violation of an ERC specification.
2. Use the name of the underlying component where it belongs (eg.
`Governor`, `ECDSA`, or `Timelock`).
- The domain prefix should be picked in the following order:
1. Use `ERC<number>` if the error is a violation of an ERC specification.
2. Use the name of the underlying component where it belongs (eg.
`Governor`, `ECDSA`, or `Timelock`).

[The Rust Style Guide]: https://doc.rust-lang.org/nightly/style-guide/

[EIP-6093]: https://eips.ethereum.org/EIPS/eip-6093

[Semantic versioning]: https://semver.org/spec/v2.0.0.html

[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/
6 changes: 4 additions & 2 deletions lib/e2e/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ pub fn provider() -> Provider {

/// Send `amount` eth to `address` in the nitro-tesnode.
pub fn fund_account(address: Address, amount: &str) -> eyre::Result<()> {
// ./test-node.bash script send-l2 --to
// address_0x01fA6bf4Ee48B6C95900BCcf9BEA172EF5DBd478 --ethamount 10
let node_script = get_node_path()?.join("test-node.bash");
if !node_script.exists() {
bail!("Test nitro node wasn't setup properly. Try to setup it first with `./scripts/nitro-testnode.sh -i -d`")
};

let output = std::process::Command::new(node_script)
.arg("script")
.arg("send-l2")
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MYDIR=$(realpath "$(dirname "$0")")
cd "$MYDIR"
cd ..

NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly}
NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly-2024-01-01}
cargo +"$NIGHTLY_TOOLCHAIN" build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort

export RPC_URL=http://localhost:8547
Expand Down
8 changes: 4 additions & 4 deletions scripts/nitro-testnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ do
HAS_DETACH=true
shift
;;
-down|--shutdown)
docker container stop "$(docker container ls -q --filter name=nitro-testnode)"
-q|--quit)
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"
echo "-q|--quit: shutdown nitro test node docker containers"
exit 0
;;
esac
Expand All @@ -46,7 +46,7 @@ then
# `release` branch.
git checkout 8cb6b84e31909157d431e7e4af9fb83799443e00 || exit

./test-node.bash --no-run --init --no-tokenbridge || exit
./test-node.bash --no-run --init || exit
fi


Expand Down

0 comments on commit 0976b1d

Please sign in to comment.