Migrate test logic from upstream
Some checks failed
Ethereum Fixturenet Stack Test / Run Ethereum Fixturenet stack test (pull_request) Failing after 34m55s

This commit is contained in:
David Boreham 2024-04-29 01:36:26 -06:00
parent 55dd7f3e97
commit b286a48280

View File

@ -18,6 +18,11 @@ test_fail_exit () {
exit 1
}
log_info () {
local message=$1
echo "$(date +"%Y-%m-%d %T"): ${message}"
}
# Sanity check the stack dir exists
if [ ! -d "${stack_name}" ]; then
test_fail_exit "stack directory not present"
@ -56,8 +61,56 @@ echo "deploy create test: passed"
$SO_COMMAND deployment --dir $test_deployment_dir start
sleep 30
timeout=900 # 15 minutes
log_info "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
log_info "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
$SO_COMMAND deployment --dir $test_deployment_dir stop
subsequent_block_number=$initial_block_number
echo "${test_name}: PASSED"
# 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
log_info "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
log_info "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))
log_info "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"
test_result=0
else
echo "Test failed: block numbers were ${initial_block_number} and ${subsequent_block_number}"
echo "Logs from stack:"
$TEST_TARGET_SO --stack fixturenet-eth deploy logs
test_result=1
fi
$SO_COMMAND deployment --dir $test_deployment_dir stop --delete-volumes
log_info "Removing cloned repositories"
rm -rf $CERC_REPO_BASE_DIR
log_info "Test finished"
exit $test_result