#!/bin/sh
set -eu

ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT"

sh scripts/check-toolchain.sh
npm run test:rehearsal
cargo metadata --locked --format-version 1 --no-deps |
  node scripts/verify-cargo-metadata.mjs
cargo test --workspace --locked
sh scripts/build-sbf.sh
sh scripts/local-validator-rehearsal.sh
node scripts/deploy-blocked.mjs && {
  echo "blocked deploy command unexpectedly succeeded" >&2
  exit 1
} || test "$?" -eq 1
