2019-08-14 11:19:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-08-21 12:45:24 +00:00
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
|
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2019-08-14 11:19:17 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
TMP_CACHE_DIR="tmpcache"
|
|
|
|
SUBREPO_DIR="tests/official/fixtures"
|
2019-08-24 01:54:04 +00:00
|
|
|
# verbosity level
|
|
|
|
[[ -z "$V" ]] && V=0
|
2019-11-01 08:44:16 +00:00
|
|
|
[[ -z "$BUILD_MSG" ]] && BUILD_MSG="Downloading official test vectors"
|
2019-08-14 11:19:17 +00:00
|
|
|
CACHE_DIR="$1" # optional parameter pointing to a CI cache dir. Without it, we just download the LFS files for a local `make test`.
|
|
|
|
|
|
|
|
[[ -d "${SUBREPO_DIR}" ]] || { echo "This script should be run from the \"nim-beacon-chain\" repo top dir."; exit 1; }
|
|
|
|
|
|
|
|
# macOS quirks
|
|
|
|
if uname | grep -qi "darwin"; then
|
|
|
|
ON_MACOS=1
|
|
|
|
STAT_FORMAT="-f %m"
|
|
|
|
else
|
|
|
|
ON_MACOS=0
|
|
|
|
STAT_FORMAT="-c %Y"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# to and from stdout
|
|
|
|
DECOMPRESS_XZ="false"
|
|
|
|
COMPRESS_XZ="false"
|
|
|
|
which 7z &>/dev/null && { DECOMPRESS_XZ="7z e -txz -bd -so"; COMPRESS_XZ="7z a -txz -an -bd -si -so"; }
|
|
|
|
which xz &>/dev/null && { DECOMPRESS_XZ="xz -d -c -T 0"; COMPRESS_XZ="xz -c -T 0"; }
|
|
|
|
|
2019-11-01 08:44:16 +00:00
|
|
|
# script output
|
|
|
|
echo -e "$BUILD_MSG"
|
|
|
|
[[ "$V" == "0" ]] && exec 3>&1 4>&2 &>/dev/null # save stdout and stderr before sending them into oblivion
|
|
|
|
|
|
|
|
#############################################
|
2019-11-14 10:40:18 +00:00
|
|
|
# Main()
|
2019-08-30 15:50:46 +00:00
|
|
|
|
|
|
|
if [[ -n "${CACHE_DIR}" ]]; then
|
2019-11-01 08:44:16 +00:00
|
|
|
# Ethereum Foundation test vectors
|
|
|
|
mkdir -p "${CACHE_DIR}/tarballs"
|
|
|
|
rm -rf "${SUBREPO_DIR}/tarballs"
|
|
|
|
ln -s "$(pwd -P)/${CACHE_DIR}/tarballs" "${SUBREPO_DIR}"
|
2019-08-14 11:19:17 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-01 08:44:16 +00:00
|
|
|
pushd "${SUBREPO_DIR}"
|
|
|
|
./download_test_vectors.sh
|
|
|
|
popd
|