From 567dadef7de6fd0272259cac1ac89ff69e749fff Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 24 Oct 2023 18:21:30 -0400 Subject: [PATCH] update fixturenet-eth test (#600) --- .github/workflows/fixturenet-eth.yml | 29 ++++++++++++++++++ tests/fixturenet-eth/run-test.sh | 46 +++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/fixturenet-eth.yml diff --git a/.github/workflows/fixturenet-eth.yml b/.github/workflows/fixturenet-eth.yml new file mode 100644 index 00000000..c9fdd4c0 --- /dev/null +++ b/.github/workflows/fixturenet-eth.yml @@ -0,0 +1,29 @@ +name: Fixturenet-Eth Test + +on: + pull_request: + branches: '*' + push: + branches: '*' + +jobs: + test: + name: "Run fixturenet-eth test suite" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: actions/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 index b5654584..743880e6 100755 --- a/tests/fixturenet-eth/run-test.sh +++ b/tests/fixturenet-eth/run-test.sh @@ -24,13 +24,45 @@ echo "$(date +"%Y-%m-%d %T"): Stack started" $TEST_TARGET_SO --stack fixturenet-eth deploy ps # echo "$(date +"%Y-%m-%d %T"): Getting stack status" # $TEST_TARGET_SO --stack fixturenet-eth deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh -echo "$(date +"%Y-%m-%d %T"): Getting initial block number" -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 120 -echo "$(date +"%Y-%m-%d %T"): Getting subsequent block number" -subsequent_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") + +timeout=900 # 15 minutes +echo "$(date +"%Y-%m-%d %T"): Getting initial block number. Timeout set to $timeout seconds" +start_time=$(date +%s) +elapsed_time=0 +initial_block_number=0 +while [ "$initial_block_number" -eq 0 ] && [ $elapsed_time -lt $timeout ]; do + sleep 10 + echo "$(date +"%Y-%m-%d %T"): Waiting for initial block..." + initial_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) +done + +subsequent_block_number=$initial_block_number + +# if initial block was 0 after timeout, assume chain did not start successfully and skip finding subsequent block +if [[ $initial_block_number -gt 0 ]]; then + timeout=300 + echo "$(date +"%Y-%m-%d %T"): Getting subsequent block number. Timeout set to $timeout seconds" + start_time=$(date +%s) + elapsed_time=0 + # wait for 5 blocks or timeout + while [ "$subsequent_block_number" -le $((initial_block_number + 5)) ] && [ $elapsed_time -lt $timeout ]; do + sleep 10 + echo "$(date +"%Y-%m-%d %T"): Waiting for five blocks or $timeout seconds..." + subsequent_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + done +fi + +# will return 0 if either of the above loops timed out block_number_difference=$((subsequent_block_number - initial_block_number)) + +echo "$(date +"%Y-%m-%d %T"): Results of block height queries:" +echo "Initial block height: $initial_block_number" +echo "Subsequent block height: $subsequent_block_number" + # Block height difference should be between 1 and some small number if [[ $block_number_difference -gt 1 && $block_number_difference -lt 100 ]]; then echo "Test passed" @@ -41,7 +73,7 @@ else $TEST_TARGET_SO --stack fixturenet-eth deploy logs test_result=1 fi -$TEST_TARGET_SO --stack fixturenet-eth deploy down +$TEST_TARGET_SO --stack fixturenet-eth deploy down --delete-volumes echo "$(date +"%Y-%m-%d %T"): Removing cloned repositories" rm -rf $CERC_REPO_BASE_DIR echo "$(date +"%Y-%m-%d %T"): Test finished"