From 08ff5c11f309c4b2341361a01880ec80252096d9 Mon Sep 17 00:00:00 2001 From: debjit Date: Fri, 11 Oct 2024 21:43:56 +0530 Subject: [PATCH] jwt fix --- .github/workflows/post-merge-run.yml | 4 ++-- scripts/generate_test_vectors.sh | 35 ++++++---------------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/.github/workflows/post-merge-run.yml b/.github/workflows/post-merge-run.yml index 611ed81..de97c63 100644 --- a/.github/workflows/post-merge-run.yml +++ b/.github/workflows/post-merge-run.yml @@ -36,8 +36,8 @@ jobs: - name: Test jq is installed run: jq --help # Vectors are already generated, but this serves as a test - # - name: Generate vectors - # run: bash ./scripts/generate_test_vectors_nethermind.sh + - name: Generate vectors + run: bash ./scripts/generate_test_vectors_nethermind.sh # Test vectors against nethermind - name: Install jwt and add to path run: cargo install jwt-cli && export PATH=$HOME/.cargo/bin:$PATH diff --git a/scripts/generate_test_vectors.sh b/scripts/generate_test_vectors.sh index 6a5791f..a789734 100755 --- a/scripts/generate_test_vectors.sh +++ b/scripts/generate_test_vectors.sh @@ -29,43 +29,23 @@ check_nethermind_availability() { # return 0 } -echo "Waiting for Nethermind to become available..." - # Wait for Nethermind to become available while ! check_nethermind_availability; do sleep 2 done -echo "Nethermind is available" - BLOCK_COUNTER=0 -MAX_RETRIES=3 function make_block() { ((BLOCK_COUNTER++)) - RETRIES=0 - - while [ $RETRIES -lt $MAX_RETRIES ]; do - HEAD_BLOCK=$(curl -X POST -H "Content-Type: application/json" \ - --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' \ - http://localhost:8545) - - # Extract block hash and proceed if it's valid - HEAD_BLOCK_HASH=$(echo $HEAD_BLOCK | jq --raw-output '.result.hash') - if [ "$HEAD_BLOCK_HASH" != "null" ]; then - echo "HEAD_BLOCK_HASH=$HEAD_BLOCK_HASH" - break - fi - - echo "Failed to get head block, retrying... ($RETRIES/$MAX_RETRIES)" - RETRIES=$((RETRIES + 1)) - sleep 2 - done - if [ $RETRIES -ge $MAX_RETRIES ]; then - echo "Failed to retrieve head block after $MAX_RETRIES attempts, exiting." - exit 1 - fi + HEAD_BLOCK=$(curl -X POST -H "Content-Type: application/json" \ + --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' \ + http://localhost:8545) + + # --raw-output remove the double quotes + HEAD_BLOCK_HASH=$(echo $HEAD_BLOCK | jq --raw-output '.result.hash') + echo HEAD_BLOCK_HASH=$HEAD_BLOCK_HASH # The ASCII representation of `2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a` JWT_SECRET="********************************" @@ -177,7 +157,6 @@ N=5 for ((i = 1; i <= N; i++)); do echo "Making block $i" - sleep 2 make_block done