Skip to content

Instantly share code, notes, and snippets.

@evertonfraga
Created November 21, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evertonfraga/824c72db5e27c46e320ad426c72e6965 to your computer and use it in GitHub Desktop.
Save evertonfraga/824c72db5e27c46e320ad426c72e6965 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# It wraps the provided JSON file and adds some metadata to it (source, commit, date).
# Based on these instructions: https://github.com/ethereumjs/ethereumjs-block/issues/55
#
# Usage:
# ./wrap-ethereum-test.sh "https://raw.githubusercontent.com/ethereum/tests/eea4bfbeec5524b2e2c0ff84c8a350fcb3edec23/BasicTests/difficultyEIP2384.json"
# The url must contain the commit hash and should point to a raw JSON file
#
URL=$1
DATE=`date +%Y-%m-%d`
COMMIT=$(echo "$URL" | sed -E 's/.+\/([a-f0-9]+)\/.+/\1/')
FILENAME=$(echo $URL | sed -E 's/.+\/([^\/]+)$/\1/')
echo "URL: $URL\nFILENAME: $FILENAME\nDATE: $DATE"
curl $URL | jq -r --arg SOURCE "$URL" --arg COMMIT "$COMMIT" --arg DATE "$DATE" '{ source: $SOURCE, commit: $COMMIT, date: $DATE, tests: .}' > $FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment