From e7a3b5b712a4e17047977c65dc2be864fcccb378 Mon Sep 17 00:00:00 2001 From: Julian Sommer <115516918+juliansommer@users.noreply.github.com> Date: Fri, 13 Mar 2026 16:07:49 +1000 Subject: [PATCH] fix: update test for explicit error handling --- .../viperblockd/viperblockd_handlers_test.go | 10 +++++++--- scripts/check-coverage.sh | 2 +- scripts/start-dev.sh | 13 ++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/hive/services/viperblockd/viperblockd_handlers_test.go b/hive/services/viperblockd/viperblockd_handlers_test.go index 04aecfc66..296f2585d 100644 --- a/hive/services/viperblockd/viperblockd_handlers_test.go +++ b/hive/services/viperblockd/viperblockd_handlers_test.go @@ -470,9 +470,13 @@ func TestIntegration_EBSUnmountInvalidJSON(t *testing.T) { require.NoError(t, err) defer nc.Close() - // Current code silently returns without responding on unmarshal failure - _, err = nc.Request("ebs.test-node.unmount", []byte("not json {{{"), 1*time.Second) - assert.Error(t, err, "expected timeout because handler silently drops invalid JSON") + // Handler responds with an error payload on invalid JSON + msg, err := nc.Request("ebs.test-node.unmount", []byte("not json {{{"), 1*time.Second) + require.NoError(t, err, "handler should respond even on invalid JSON") + + var resp types.EBSUnMountResponse + require.NoError(t, json.Unmarshal(msg.Data, &resp)) + assert.Contains(t, resp.Error, "bad request") } // --- ebs.delete with VB instance (StopWALSyncer path) --- diff --git a/scripts/check-coverage.sh b/scripts/check-coverage.sh index 566df0a84..0406c59c2 100755 --- a/scripts/check-coverage.sh +++ b/scripts/check-coverage.sh @@ -26,7 +26,7 @@ if [[ -z "$QUIET" ]]; then go tool cover -func="$PROFILE" | tail -1 fi -PASS=$(echo "$TOTAL >= $MIN" | bc -l) +PASS=$(awk "BEGIN {print ($TOTAL >= $MIN) ? 1 : 0}") if [[ "$PASS" != "1" ]]; then echo "ERROR: Total coverage ${TOTAL}% is below minimum ${MIN}%" exit 1 diff --git a/scripts/start-dev.sh b/scripts/start-dev.sh index 22d66c267..6dd2c60ae 100755 --- a/scripts/start-dev.sh +++ b/scripts/start-dev.sh @@ -255,20 +255,15 @@ if has_service "nats"; then set_oom_score "nats" "-500" check_service "NATS" "$NATS_CHECK_HOST" "4222" - # Ensure NATS JetStream is ready before Predastore starts. + # Wait for NATS JetStream to be ready before Predastore starts. # Predastore lazily opens IAM KV buckets — it starts with config-only auth # and activates IAM auth once the hive daemon creates the KV buckets. echo "🔍 Waiting for NATS JetStream..." NATS_JS_READY=false for i in $(seq 1 15); do - if nats -s nats://$NATS_CHECK_HOST:4222 stream ls --names 2>/dev/null | grep -q "KV_" 2>/dev/null; then - echo " ✅ NATS JetStream is ready (KV streams found)" - NATS_JS_READY=true - break - fi - # JetStream may be up with no KV buckets yet (fresh install before admin init) - if nats -s nats://$NATS_CHECK_HOST:4222 account info 2>/dev/null | grep -q "JetStream" 2>/dev/null; then - echo " ✅ NATS JetStream is ready (no KV buckets yet — run 'hive admin init' to bootstrap)" + # Send a NATS INFO probe — JetStream-enabled servers include "jetstream" in the INFO response + if echo "" | nc -w 1 "$NATS_CHECK_HOST" 4222 2>/dev/null | grep -q "jetstream"; then + echo " ✅ NATS JetStream is ready" NATS_JS_READY=true break fi