diff --git a/.github/workflows/per-pr.yml b/.github/workflows/per-pr.yml index 8ac35b08..fab6178a 100644 --- a/.github/workflows/per-pr.yml +++ b/.github/workflows/per-pr.yml @@ -46,3 +46,20 @@ 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: Start kurtosis engine + run: kurtosis engine start + + - name: Run E2E tests + run: just test-e2e + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..245c3963 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "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/lib/bats-assert + url = https://github.com/bats-core/bats-assert.git diff --git a/Justfile b/Justfile new file mode 100644 index 00000000..360c3bd7 --- /dev/null +++ b/Justfile @@ -0,0 +1,2 @@ +test-e2e: + bats test/e2e/**/*.bats \ No newline at end of file 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 diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..ea2b7dfb --- /dev/null +++ b/mise.toml @@ -0,0 +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" diff --git a/test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml b/test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml new file mode 100644 index 00000000..4eff93ec --- /dev/null +++ b/test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml @@ -0,0 +1,18 @@ +ethereum_package: + participants: + - el_type: reth + cl_type: lighthouse +optimism_package: + 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/isthmus/isthmus.bats b/test/e2e/isthmus/isthmus.bats new file mode 100644 index 00000000..07ba5f91 --- /dev/null +++ b/test/e2e/isthmus/isthmus.bats @@ -0,0 +1,31 @@ +setup() { + 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 $BATS_TEST_DIRNAME/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 port print $ENCLAVE_ID $OP_GETH_SERVICE_UUID rpc) + 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 diff --git a/test/lib/bats-assert b/test/lib/bats-assert new file mode 160000 index 00000000..e2d855bc --- /dev/null +++ b/test/lib/bats-assert @@ -0,0 +1 @@ +Subproject commit e2d855bc78619ee15b0c702b5c30fb074101159f diff --git a/test/lib/bats-support b/test/lib/bats-support new file mode 160000 index 00000000..9bf10e87 --- /dev/null +++ b/test/lib/bats-support @@ -0,0 +1 @@ +Subproject commit 9bf10e876dd6b624fe44423f0b35e064225f7556