From 19f37d267dde40500da94be094dbbddec7b69b5b Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 10:46:44 -0800 Subject: [PATCH 01/19] chore: Add BATS --- .gitmodules | 9 +++++++++ test/e2e/lib/bats | 1 + test/e2e/lib/bats-assert | 1 + test/e2e/lib/bats-support | 1 + 4 files changed, 12 insertions(+) create mode 100644 .gitmodules create mode 160000 test/e2e/lib/bats create mode 160000 test/e2e/lib/bats-assert create mode 160000 test/e2e/lib/bats-support diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..b49d8eeb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "test/e2e/lib/bats"] + path = test/e2e/lib/bats + url = https://github.com/bats-core/bats-core.git +[submodule "test/e2e/lib/bats-support"] + path = test/e2e/lib/bats-support + url = https://github.com/bats-core/bats-support.git +[submodule "test/e2e/lib/bats-assert"] + path = test/e2e/lib/bats-assert + url = https://github.com/bats-core/bats-assert.git diff --git a/test/e2e/lib/bats b/test/e2e/lib/bats new file mode 160000 index 00000000..7ca23b1e --- /dev/null +++ b/test/e2e/lib/bats @@ -0,0 +1 @@ +Subproject commit 7ca23b1e9daf4c7cfafdf398458c210af3299781 diff --git a/test/e2e/lib/bats-assert b/test/e2e/lib/bats-assert new file mode 160000 index 00000000..e2d855bc --- /dev/null +++ b/test/e2e/lib/bats-assert @@ -0,0 +1 @@ +Subproject commit e2d855bc78619ee15b0c702b5c30fb074101159f diff --git a/test/e2e/lib/bats-support b/test/e2e/lib/bats-support new file mode 160000 index 00000000..9bf10e87 --- /dev/null +++ b/test/e2e/lib/bats-support @@ -0,0 +1 @@ +Subproject commit 9bf10e876dd6b624fe44423f0b35e064225f7556 From 3a70d8f78400a0fe6f669c0499679866db6482c4 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 15:22:59 -0800 Subject: [PATCH 02/19] chore: Add mise --- mise.toml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 mise.toml diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..15371c93 --- /dev/null +++ b/mise.toml @@ -0,0 +1,9 @@ +[tools] + +# Core dependencies +jq = "1.7.1" +just = "1.37.0" +"ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "2.1.0" + +# Code coverage +"ubi:codecov/codecov-cli" = "v10.0.1" From b68ae86d625534f5d1cbf9620228f6c1584c7881 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 15:23:06 -0800 Subject: [PATCH 03/19] chore: Add Justfile --- Justfile | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Justfile diff --git a/Justfile b/Justfile new file mode 100644 index 00000000..cf246f8f --- /dev/null +++ b/Justfile @@ -0,0 +1,2 @@ +test-e2e: + ./test/e2e/lib/bats/bin/bats test/e2e/tests/*.bats \ No newline at end of file From 5a9c3c7f4d34557cbb07316c90321c4e46cbb665 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 15:23:41 -0800 Subject: [PATCH 04/19] chore: Add E2E tests to the workflow --- .github/workflows/per-pr.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/per-pr.yml b/.github/workflows/per-pr.yml index 8ac35b08..019211f7 100644 --- a/.github/workflows/per-pr.yml +++ b/.github/workflows/per-pr.yml @@ -46,3 +46,17 @@ jobs: - name: Kurtosis Lint run: kurtosis lint ${{ github.workspace }} + test-e2e: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + uses: jdx/mise-action@v2 + + - name: Run E2E tests + run: just test-e2e + From 2f45a790c04832745cc279577b8879a1e836fc9a Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 18:35:44 -0800 Subject: [PATCH 05/19] chore: Add a stub of an E2E test --- .../tests/assets/kurtosis_args_isthmus.yaml | 20 +++++++++++ test/e2e/tests/isthmus.bats | 33 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/e2e/tests/assets/kurtosis_args_isthmus.yaml create mode 100644 test/e2e/tests/isthmus.bats diff --git a/test/e2e/tests/assets/kurtosis_args_isthmus.yaml b/test/e2e/tests/assets/kurtosis_args_isthmus.yaml new file mode 100644 index 00000000..a9e89e53 --- /dev/null +++ b/test/e2e/tests/assets/kurtosis_args_isthmus.yaml @@ -0,0 +1,20 @@ +ethereum_package: + participants: + - el_type: reth + cl_type: lighthouse +optimism_package: + op_contract_deployer_params: + image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.11 + chains: + - network_params: + isthmus_time_offset: 0 + participants: + - el_type: op-geth + el_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest + cl_type: op-node + cl_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop + cl_extra_params: + - "--l1.trustrpc=true" + batcher_params: + extra_params: + - "--throttle-interval=0" diff --git a/test/e2e/tests/isthmus.bats b/test/e2e/tests/isthmus.bats new file mode 100644 index 00000000..2135f07d --- /dev/null +++ b/test/e2e/tests/isthmus.bats @@ -0,0 +1,33 @@ +setup() { + load "../lib/bats-support/load.bash" + load "../lib/bats-assert/load.bash" +} + +teardown() { + +} + +@test "should have isthmus time if isthmus_time_offset is configured" { + local ENCLAVE_ID=op-isthmus--001 + + # First we start the enclave + run kurtosis run --enclave $ENCLAVE_ID . --args-file test/e2e/tests/assets/kurtosis_args_isthmus.yaml + assert_success + + # We get the UUID of the op-geth service + local OP_GETH_SERVICE_UUID=$(kurtosis enclave inspect $ENCLAVE_ID --full-uuids| grep op-el-1-op-geth-op-node-op-kurtosis | awk '{print $1;}') + assert [ -n "$OP_GETH_SERVICE_UUID" ] + + # Now we find its RPC URL + local OP_GETH_RPC_URL=$(kurtosis service inspect $ENCLAVE_ID $OP_GETH_SERVICE_UUID | grep ' rpc:' | awk '{print $4;}') + assert [ -n "$OP_GETH_RPC_URL" ] + + # We ask the RPC for the node info + local OP_GETH_NODE_INFO_JSON=$(curl -s -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' $OP_GETH_RPC_URL) + + # And finally we find the isthmusTime and make sure it's defined + local OP_GETH_ISTHMUS_TIME=$(jq '.result.protocols.eth.config.isthmusTime' <<< $OP_GETH_NODE_INFO_JSON) + assert_equal "$OP_GETH_ISTHMUS_TIME" "0" + + kurtosis enclave rm -f $ENCLAVE_ID +} \ No newline at end of file From 37fd80f009940af81cb8089f0fd67e4ea1498c63 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 18:48:29 -0800 Subject: [PATCH 06/19] chore: Drop the op-deployer version overwrite in E2E test --- test/e2e/tests/assets/kurtosis_args_isthmus.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/tests/assets/kurtosis_args_isthmus.yaml b/test/e2e/tests/assets/kurtosis_args_isthmus.yaml index a9e89e53..4eff93ec 100644 --- a/test/e2e/tests/assets/kurtosis_args_isthmus.yaml +++ b/test/e2e/tests/assets/kurtosis_args_isthmus.yaml @@ -3,8 +3,6 @@ ethereum_package: - el_type: reth cl_type: lighthouse optimism_package: - op_contract_deployer_params: - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.11 chains: - network_params: isthmus_time_offset: 0 From c0ed4b92cf94294b9de0c42b9a559f95b2f939e0 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 18:49:04 -0800 Subject: [PATCH 07/19] fix: Drop empty teardown --- test/e2e/tests/isthmus.bats | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/e2e/tests/isthmus.bats b/test/e2e/tests/isthmus.bats index 2135f07d..2f8f2043 100644 --- a/test/e2e/tests/isthmus.bats +++ b/test/e2e/tests/isthmus.bats @@ -3,10 +3,6 @@ setup() { load "../lib/bats-assert/load.bash" } -teardown() { - -} - @test "should have isthmus time if isthmus_time_offset is configured" { local ENCLAVE_ID=op-isthmus--001 From e99d91ac26f6309c729ca12c4581320ab2980de1 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Sun, 26 Jan 2025 18:49:46 -0800 Subject: [PATCH 08/19] chore: Start the engine --- .github/workflows/per-pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/per-pr.yml b/.github/workflows/per-pr.yml index 019211f7..fab6178a 100644 --- a/.github/workflows/per-pr.yml +++ b/.github/workflows/per-pr.yml @@ -57,6 +57,9 @@ jobs: - name: Install dependencies uses: jdx/mise-action@v2 + - name: Start kurtosis engine + run: kurtosis engine start + - name: Run E2E tests run: just test-e2e From 876c16ae27afe9675d31c91a1ea186b186bed296 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 08:54:25 -0800 Subject: [PATCH 09/19] chore: Downgrade kurtosis version --- mise.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mise.toml b/mise.toml index 15371c93..cd2b02e9 100644 --- a/mise.toml +++ b/mise.toml @@ -3,7 +3,7 @@ # Core dependencies jq = "1.7.1" just = "1.37.0" -"ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "2.1.0" +"ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "1.4.3" # Code coverage "ubi:codecov/codecov-cli" = "v10.0.1" From e4b6ede23074cb327d7ad55a4af2f8ccc6c08950 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 08:55:32 -0800 Subject: [PATCH 10/19] chore: Drop unused codecov-cli from mise.toml --- mise.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/mise.toml b/mise.toml index cd2b02e9..39828b66 100644 --- a/mise.toml +++ b/mise.toml @@ -4,6 +4,3 @@ jq = "1.7.1" just = "1.37.0" "ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "1.4.3" - -# Code coverage -"ubi:codecov/codecov-cli" = "v10.0.1" From 583541b7ee2070e7eb315bbbab4b0df9fcb305cf Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 08:56:23 -0800 Subject: [PATCH 11/19] chore: Whitespace --- test/e2e/tests/isthmus.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/tests/isthmus.bats b/test/e2e/tests/isthmus.bats index 2f8f2043..a04aaa41 100644 --- a/test/e2e/tests/isthmus.bats +++ b/test/e2e/tests/isthmus.bats @@ -11,7 +11,7 @@ setup() { assert_success # We get the UUID of the op-geth service - local OP_GETH_SERVICE_UUID=$(kurtosis enclave inspect $ENCLAVE_ID --full-uuids| grep op-el-1-op-geth-op-node-op-kurtosis | awk '{print $1;}') + local OP_GETH_SERVICE_UUID=$(kurtosis enclave inspect $ENCLAVE_ID --full-uuids | grep op-el-1-op-geth-op-node-op-kurtosis | awk '{print $1;}') assert [ -n "$OP_GETH_SERVICE_UUID" ] # Now we find its RPC URL From ab4bdb847a423027a145cc7c5dc5f7bf5fc54611 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 09:48:25 -0800 Subject: [PATCH 12/19] chore: Make bats binary nicer --- Justfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Justfile b/Justfile index cf246f8f..4347e3d7 100644 --- a/Justfile +++ b/Justfile @@ -1,2 +1,8 @@ +# BATS (bash automated testing system) is a binary installed using git submodules +# +# Since the path to the binary is wild, we alias it for ease of use +bats *args="": + ./test/e2e/lib/bats/bin/bats {{args}} + test-e2e: - ./test/e2e/lib/bats/bin/bats test/e2e/tests/*.bats \ No newline at end of file + just bats test/e2e/tests/*.bats \ No newline at end of file From 9e1b3a8c019fbcc3e8e3acf506fbc31c046005bd Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 09:48:38 -0800 Subject: [PATCH 13/19] chore: Add a docs section about mise --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index dc86ff53..17347934 100644 --- a/README.md +++ b/README.md @@ -623,6 +623,32 @@ kurtosis service stop kurtosis service start ``` +## Development + +### Development environment + +We use [`mise`](https://mise.jdx.dev/) as a dependency manager for these tools. +Once properly installed, `mise` will provide the correct versions for each tool. `mise` does not +replace any other installations of these binaries and will only serve these binaries when you are +working inside of the `optimism-package` directory. + +#### Install `mise` + +Install `mise` by following the instructions provided on the +[Getting Started page](https://mise.jdx.dev/getting-started.html#_1-install-mise-cli). + +#### Install dependencies + +```sh +mise install +``` + +### Testing + +We use [`BATS`](https://bats-core.readthedocs.io/en/stable/index.html), _Bash Automated Testing System_ to write tests for this repository. + +`BATS` is installed as a git submodule so make sure to clone the repo with submodules if you want to run the test suite. + ## Contributing If you have made changes and would like to submit a PR, test locally and make sure to run `lint` on your changes From 72752051b40ce1cda9ebfc19177001ba9ad6f212 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 12:05:29 -0800 Subject: [PATCH 14/19] chore: Install BATS using mise --- mise.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/mise.toml b/mise.toml index 39828b66..ea2b7dfb 100644 --- a/mise.toml +++ b/mise.toml @@ -1,6 +1,7 @@ [tools] # Core dependencies +bats = "1.11.1" jq = "1.7.1" just = "1.37.0" "ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "1.4.3" From f329d812bec76d988c11b82ec257d0b92e35bf3f Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 12:06:06 -0800 Subject: [PATCH 15/19] chore: Drop bats alias from Justfile --- Justfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Justfile b/Justfile index 4347e3d7..5b17b837 100644 --- a/Justfile +++ b/Justfile @@ -1,8 +1,2 @@ -# BATS (bash automated testing system) is a binary installed using git submodules -# -# Since the path to the binary is wild, we alias it for ease of use -bats *args="": - ./test/e2e/lib/bats/bin/bats {{args}} - test-e2e: - just bats test/e2e/tests/*.bats \ No newline at end of file + bats test/e2e/tests/*.bats \ No newline at end of file From b75bbceb077495d84e76342b241cdd64eaaba6c1 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 12:06:33 -0800 Subject: [PATCH 16/19] chore: Drop the bats submodule --- .gitmodules | 3 --- test/e2e/lib/bats | 1 - 2 files changed, 4 deletions(-) delete mode 160000 test/e2e/lib/bats diff --git a/.gitmodules b/.gitmodules index b49d8eeb..2cb317c3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "test/e2e/lib/bats"] - path = test/e2e/lib/bats - url = https://github.com/bats-core/bats-core.git [submodule "test/e2e/lib/bats-support"] path = test/e2e/lib/bats-support url = https://github.com/bats-core/bats-support.git diff --git a/test/e2e/lib/bats b/test/e2e/lib/bats deleted file mode 160000 index 7ca23b1e..00000000 --- a/test/e2e/lib/bats +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ca23b1e9daf4c7cfafdf398458c210af3299781 From b27f0239542df8c1bf145bb9a069e9818ef7b5f9 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 12:25:24 -0800 Subject: [PATCH 17/19] chore: Move bats libs --- .gitmodules | 4 ++-- test/{e2e => }/lib/bats-assert | 0 test/{e2e => }/lib/bats-support | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename test/{e2e => }/lib/bats-assert (100%) rename test/{e2e => }/lib/bats-support (100%) diff --git a/.gitmodules b/.gitmodules index 2cb317c3..245c3963 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "test/e2e/lib/bats-support"] - path = test/e2e/lib/bats-support + path = test/lib/bats-support url = https://github.com/bats-core/bats-support.git [submodule "test/e2e/lib/bats-assert"] - path = test/e2e/lib/bats-assert + path = test/lib/bats-assert url = https://github.com/bats-core/bats-assert.git diff --git a/test/e2e/lib/bats-assert b/test/lib/bats-assert similarity index 100% rename from test/e2e/lib/bats-assert rename to test/lib/bats-assert diff --git a/test/e2e/lib/bats-support b/test/lib/bats-support similarity index 100% rename from test/e2e/lib/bats-support rename to test/lib/bats-support From 9e54fe2434de67e260233306da79cdc6a1a48b80 Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Jan 2025 12:29:08 -0800 Subject: [PATCH 18/19] chore: Move tests around --- Justfile | 2 +- .../{tests => isthmus}/assets/kurtosis_args_isthmus.yaml | 0 test/e2e/{tests => isthmus}/isthmus.bats | 8 +++++--- 3 files changed, 6 insertions(+), 4 deletions(-) rename test/e2e/{tests => isthmus}/assets/kurtosis_args_isthmus.yaml (100%) rename test/e2e/{tests => isthmus}/isthmus.bats (78%) diff --git a/Justfile b/Justfile index 5b17b837..360c3bd7 100644 --- a/Justfile +++ b/Justfile @@ -1,2 +1,2 @@ test-e2e: - bats test/e2e/tests/*.bats \ No newline at end of file + bats test/e2e/**/*.bats \ No newline at end of file diff --git a/test/e2e/tests/assets/kurtosis_args_isthmus.yaml b/test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml similarity index 100% rename from test/e2e/tests/assets/kurtosis_args_isthmus.yaml rename to test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml diff --git a/test/e2e/tests/isthmus.bats b/test/e2e/isthmus/isthmus.bats similarity index 78% rename from test/e2e/tests/isthmus.bats rename to test/e2e/isthmus/isthmus.bats index a04aaa41..11779f0e 100644 --- a/test/e2e/tests/isthmus.bats +++ b/test/e2e/isthmus/isthmus.bats @@ -1,13 +1,15 @@ setup() { - load "../lib/bats-support/load.bash" - load "../lib/bats-assert/load.bash" + load "../../lib/bats-support/load.bash" + load "../../lib/bats-assert/load.bash" } @test "should have isthmus time if isthmus_time_offset is configured" { local ENCLAVE_ID=op-isthmus--001 + local ARGS_FILE=$BATS_TEST_DIRNAME/assets/kurtosis_args_isthmus.yaml + assert [ -f "$ARGS_FILE" ] # First we start the enclave - run kurtosis run --enclave $ENCLAVE_ID . --args-file test/e2e/tests/assets/kurtosis_args_isthmus.yaml + run kurtosis run --enclave $ENCLAVE_ID . --args-file $BATS_TEST_DIRNAME/assets/kurtosis_args_isthmus.yaml assert_success # We get the UUID of the op-geth service From ed4783ba4451a3f0a2f569343f0436cf39814a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jakub=20Nani=C5=A1ta?= Date: Wed, 30 Apr 2025 23:11:22 -0700 Subject: [PATCH 19/19] Update test/e2e/isthmus/isthmus.bats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Samuel Laferriere Signed-off-by: Ján Jakub Naništa --- test/e2e/isthmus/isthmus.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/isthmus/isthmus.bats b/test/e2e/isthmus/isthmus.bats index 11779f0e..07ba5f91 100644 --- a/test/e2e/isthmus/isthmus.bats +++ b/test/e2e/isthmus/isthmus.bats @@ -17,7 +17,7 @@ setup() { assert [ -n "$OP_GETH_SERVICE_UUID" ] # Now we find its RPC URL - local OP_GETH_RPC_URL=$(kurtosis service inspect $ENCLAVE_ID $OP_GETH_SERVICE_UUID | grep ' rpc:' | awk '{print $4;}') + local OP_GETH_RPC_URL=$(kurtosis port print $ENCLAVE_ID $OP_GETH_SERVICE_UUID rpc) assert [ -n "$OP_GETH_RPC_URL" ] # We ask the RPC for the node info