|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: LicenseRef-DCL-1.0 |
| 3 | +# SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd |
| 4 | +# |
| 5 | +# Prints "OK" iff every version published to the soldeer registry for |
| 6 | +# `rain-math-float` has a full suite of pinned deploy constants in |
| 7 | +# LibDecimalFloatDeploy.sol: a log-tables address + codehash and a DecimalFloat |
| 8 | +# address + codehash, each suffixed with the version. |
| 9 | +# |
| 10 | +# Consumed by LibDecimalFloatDeployTaggedConstants.t.sol via FFI. Output is one |
| 11 | +# of: |
| 12 | +# OK - every published version has its full constant suite |
| 13 | +# MISSING: <names...> - one or more expected constants are absent |
| 14 | +# SKIP: <reason> - the registry could not be reached (nothing verified) |
| 15 | +# |
| 16 | +# Always exits 0 so the test sees the message rather than an ffi failure. |
| 17 | + |
| 18 | +lib="src/lib/deploy/LibDecimalFloatDeploy.sol" |
| 19 | + |
| 20 | +versions=$( |
| 21 | + curl -fsS --connect-timeout 5 --max-time 20 --retry 2 --retry-delay 1 \ |
| 22 | + "https://api.soldeer.xyz/api/v1/revision?project_name=rain-math-float" 2>/dev/null \ |
| 23 | + | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u |
| 24 | +) |
| 25 | + |
| 26 | +if [ -z "$versions" ]; then |
| 27 | + printf 'SKIP: could not fetch published soldeer versions' |
| 28 | + exit 0 |
| 29 | +fi |
| 30 | + |
| 31 | +# The deploy constants that must be pinned for every published version, suffixed |
| 32 | +# with the version (dots replaced by underscores). |
| 33 | +bases="ZOLTU_DEPLOYED_LOG_TABLES_ADDRESS \ |
| 34 | +LOG_TABLES_DATA_CONTRACT_HASH \ |
| 35 | +ZOLTU_DEPLOYED_DECIMAL_FLOAT_ADDRESS \ |
| 36 | +DECIMAL_FLOAT_CONTRACT_HASH" |
| 37 | + |
| 38 | +missing="" |
| 39 | +for v in $versions; do |
| 40 | + suffix=$(printf '%s' "$v" | tr . _) |
| 41 | + for b in $bases; do |
| 42 | + name="${b}_${suffix}" |
| 43 | + grep -qE "constant ${name} =" "$lib" || missing="${missing} ${name}" |
| 44 | + done |
| 45 | +done |
| 46 | + |
| 47 | +if [ -n "$missing" ]; then |
| 48 | + printf 'MISSING:%s' "$missing" |
| 49 | +else |
| 50 | + printf 'OK' |
| 51 | +fi |
0 commit comments