From d1cada5029692aec1b0f76f5bdd17468cf85909f Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 19 Apr 2023 18:25:49 -0600 Subject: [PATCH] Add fixturenet-eth test (#356) * Add fixturenet-eth test --- .gitea/fixturenet-eth-test.yml | 27 ++++++++++++++++++++++ tests/fixturenet-eth/run-test.sh | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .gitea/fixturenet-eth-test.yml create mode 100755 tests/fixturenet-eth/run-test.sh diff --git a/.gitea/fixturenet-eth-test.yml b/.gitea/fixturenet-eth-test.yml new file mode 100644 index 00000000..6b764664 --- /dev/null +++ b/.gitea/fixturenet-eth-test.yml @@ -0,0 +1,27 @@ +name: Fixturenet-Eth-Test + +on: + push: + branches: 'ci-test' + +jobs: + test: + name: "Run an Ethereum fixturenet test" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: cerc-io/setup-python@v4 + with: + python-version: '3.8' + - name: "Print Python version" + run: python3 --version + - name: "Install shiv" + run: pip install shiv + - name: "Generate build version file" + run: ./scripts/create_build_tag_file.sh + - name: "Build local shiv package" + run: ./scripts/build_shiv_package.sh + - name: "Run fixturenet-eth tests" + run: ./tests/fixturenet-eth/run-test.sh diff --git a/tests/fixturenet-eth/run-test.sh b/tests/fixturenet-eth/run-test.sh new file mode 100755 index 00000000..3fd4cd59 --- /dev/null +++ b/tests/fixturenet-eth/run-test.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi +set -e +echo "Running stack-orchestrator Ethereum fixturenet test" +# Bit of a hack, test the most recent package +TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) +# Set a new unique repo dir +export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-fixturenet-eth-test.XXXXXXXXXX) +echo "Testing this package: $TEST_TARGET_SO" +echo "Test version command" +reported_version_string=$( $TEST_TARGET_SO version ) +echo "Version reported is: ${reported_version_string}" +echo "Cloning repositories into: $CERC_REPO_BASE_DIR" +$TEST_TARGET_SO --stack fixturenet-eth setup-repositories +$TEST_TARGET_SO --stack fixturenet-eth build-containers +$TEST_TARGET_SO --stack fixturenet-eth deploy up +# Verify that the fixturenet is up and running +$TEST_TARGET_SO --stack fixturenet-eth deploy ps +$TEST_TARGET_SO --stack fixturenet-eth deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh +initial_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") +# Check that the block number increases some time later +sleep 12 +subsequent_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") +block_number_difference=$((subsequent_block_number - initial_block_number)) +# Block height difference should be between 1 and some small number +if [[ $block_number_difference -gt 1 && $block_number_difference -lt 10 ]]; then + echo "Test passed" + test_result=0 +else + echo "Test failed: block numbers were ${initial_block_number} and ${subsequent_block_number}" + test_result=1 +fi +$TEST_TARGET_SO --stack fixturenet-eth deploy down +echo "Removing cloned repositories" +rm -rf $CERC_REPO_BASE_DIR +exit $test_result