cgh: fix rpc blockNumber and bash warnings

This commit is contained in:
marcello33 2024-11-13 14:45:41 +01:00
parent 927db07fc4
commit baa8a2bb63
No known key found for this signature in database
GPG key ID: 06128777E3C36B16
3 changed files with 15 additions and 10 deletions

View file

@ -11,5 +11,5 @@ do
fi fi
done done
echo $peers echo "$peers"
echo $block echo "$block"

View file

@ -18,8 +18,8 @@ do
exit 1 exit 1
fi fi
if (( $balance > $balanceInit )); then if (( balance > balanceInit )); then
if [ $stateSyncFound != "true" ]; then if [ "$stateSyncFound" != "true" ]; then
stateSyncTime=$(( SECONDS - start_time )) stateSyncTime=$(( SECONDS - start_time ))
stateSyncFound="true" stateSyncFound="true"
fi fi
@ -27,18 +27,18 @@ do
checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id)
if [ $checkpointID != "null" ]; then if [ "$checkpointID" != "null" ]; then
if [ $checkpointFound != "true" ]; then if [ "$checkpointFound" != "true" ]; then
checkpointTime=$(( SECONDS - start_time )) checkpointTime=$(( SECONDS - start_time ))
checkpointFound="true" checkpointFound="true"
fi fi
fi fi
if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then if [ "$stateSyncFound" == "true" ] && [ "$checkpointFound" == "true" ]; then
break break
fi fi
done done
echo "Both state sync and checkpoint went through. All tests have passed!" echo "Both state sync and checkpoint went through. All tests have passed!"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))" echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime%3600/60)) $((stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))" echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime%3600/60)) $((checkpointTime%60)))"

View file

@ -3,6 +3,7 @@ package server
import ( import (
"context" "context"
"errors" "errors"
"strconv"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
@ -113,6 +114,10 @@ func getRpcBlockNumberFromString(blockNumber string) (rpc.BlockNumber, error) {
case "safe": case "safe":
return rpc.SafeBlockNumber, nil return rpc.SafeBlockNumber, nil
default: default:
blckNum, err := strconv.ParseUint(blockNumber, 10, 64)
if err != nil {
return rpc.BlockNumber(0), errors.New("invalid block number") return rpc.BlockNumber(0), errors.New("invalid block number")
} }
return rpc.BlockNumber(blckNum), nil
}
} }