Fixes the group id parsing
This commit is contained in:
@@ -143,6 +143,33 @@ expect_contains() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------- JSON helpers --------------------------------------------------------
|
||||||
|
|
||||||
|
# Extract MLS group ID as lowercase hex from wn JSON output.
|
||||||
|
# Handles both formats:
|
||||||
|
# - plain hex string (from `groups list`)
|
||||||
|
# - {"value":{"vec":[...]}} serde struct (from `groups create`)
|
||||||
|
# - flat byte array [n, ...] (from some responses)
|
||||||
|
# Input: JSON string via stdin; optional 2nd arg = field name (default: mls_group_id)
|
||||||
|
jq_group_id() {
|
||||||
|
local field="${1:-mls_group_id}"
|
||||||
|
jq -r --arg f "$field" '
|
||||||
|
def byte2hex:
|
||||||
|
. as $n |
|
||||||
|
[($n / 16 | floor), ($n % 16)] |
|
||||||
|
map(if . < 10 then (48 + .) else (87 + .) end) |
|
||||||
|
implode;
|
||||||
|
(.result // .) |
|
||||||
|
.[$f] |
|
||||||
|
if type == "string" then .
|
||||||
|
elif (type == "object" and (.value.vec != null)) then
|
||||||
|
[.value.vec[] | byte2hex] | join("")
|
||||||
|
elif type == "array" then
|
||||||
|
[.[] | byte2hex] | join("")
|
||||||
|
else empty end
|
||||||
|
' 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
# ------- polling helpers -----------------------------------------------------
|
# ------- polling helpers -----------------------------------------------------
|
||||||
|
|
||||||
# wait_for_invite <B|C> <timeout-seconds>
|
# wait_for_invite <B|C> <timeout-seconds>
|
||||||
@@ -154,10 +181,10 @@ wait_for_invite() {
|
|||||||
while [[ $(date +%s) -lt $deadline ]]; do
|
while [[ $(date +%s) -lt $deadline ]]; do
|
||||||
if [[ "$who" == "B" ]]; then
|
if [[ "$who" == "B" ]]; then
|
||||||
gid=$(wn_b_json groups invites 2>/dev/null \
|
gid=$(wn_b_json groups invites 2>/dev/null \
|
||||||
| jq -r '.[0].group_id // .[0].mls_group_id // empty' 2>/dev/null || true)
|
| jq -c '.[0] // empty' 2>/dev/null | jq_group_id || true)
|
||||||
else
|
else
|
||||||
gid=$(wn_c_json groups invites 2>/dev/null \
|
gid=$(wn_c_json groups invites 2>/dev/null \
|
||||||
| jq -r '.[0].group_id // .[0].mls_group_id // empty' 2>/dev/null || true)
|
| jq -c '.[0] // empty' 2>/dev/null | jq_group_id || true)
|
||||||
fi
|
fi
|
||||||
if [[ -n "${gid:-}" ]]; then
|
if [[ -n "${gid:-}" ]]; then
|
||||||
printf '%s\n' "$gid"
|
printf '%s\n' "$gid"
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ test_03_wn_creates_group() {
|
|||||||
local out gid
|
local out gid
|
||||||
out=$(wn_b --json groups create "Interop-03" "$A_NPUB" 2>>"$LOG_FILE")
|
out=$(wn_b --json groups create "Interop-03" "$A_NPUB" 2>>"$LOG_FILE")
|
||||||
printf 'wn groups create raw output: %s\n' "$out" >>"$LOG_FILE"
|
printf 'wn groups create raw output: %s\n' "$out" >>"$LOG_FILE"
|
||||||
gid=$(printf '%s' "$out" | jq -r '.group_id // .mls_group_id // empty' 2>/dev/null || true)
|
gid=$(printf '%s' "$out" | jq_group_id)
|
||||||
if [[ -z "$gid" ]]; then
|
if [[ -z "$gid" ]]; then
|
||||||
fail_msg "could not parse group_id from 'wn groups create' output"
|
fail_msg "could not parse group_id from 'wn groups create' output"
|
||||||
info "raw output: $out"
|
info "raw output: $out"
|
||||||
@@ -425,7 +425,7 @@ test_04_three_member_group() {
|
|||||||
warn "GROUP_02 not set (Test 02 likely skipped/failed); creating new group here"
|
warn "GROUP_02 not set (Test 02 likely skipped/failed); creating new group here"
|
||||||
local out
|
local out
|
||||||
out=$(wn_b --json groups create "Interop-04-bootstrap" "$A_NPUB" 2>>"$LOG_FILE")
|
out=$(wn_b --json groups create "Interop-04-bootstrap" "$A_NPUB" 2>>"$LOG_FILE")
|
||||||
gid=$(printf '%s' "$out" | jq -r '.group_id // .mls_group_id // empty' 2>/dev/null || true)
|
gid=$(printf '%s' "$out" | jq_group_id)
|
||||||
save_state GROUP_02 "$gid"
|
save_state GROUP_02 "$gid"
|
||||||
prompt_human "In Amethyst, accept the new group invite 'Interop-04-bootstrap'."
|
prompt_human "In Amethyst, accept the new group invite 'Interop-04-bootstrap'."
|
||||||
fi
|
fi
|
||||||
@@ -469,8 +469,9 @@ test_05_wn_adds_amethyst_existing() {
|
|||||||
|
|
||||||
step "B creates group with only C, then adds A"
|
step "B creates group with only C, then adds A"
|
||||||
local out gid
|
local out gid
|
||||||
out=$(wn_b --json groups create "Interop-05" "$C_NPUB" 2>&1 | tee -a "$LOG_FILE")
|
out=$(wn_b --json groups create "Interop-05" "$C_NPUB" 2>>"$LOG_FILE")
|
||||||
gid=$(printf '%s' "$out" | jq -r '.group_id // .mls_group_id // empty')
|
printf 'wn groups create raw output: %s\n' "$out" >>"$LOG_FILE"
|
||||||
|
gid=$(printf '%s' "$out" | jq_group_id)
|
||||||
if [[ -z "$gid" ]]; then
|
if [[ -z "$gid" ]]; then
|
||||||
fail_msg "could not create Interop-05"
|
fail_msg "could not create Interop-05"
|
||||||
record_result "05 wn adds Amethyst existing" fail "create failed"
|
record_result "05 wn adds Amethyst existing" fail "create failed"
|
||||||
@@ -748,8 +749,9 @@ test_12_offline_catchup() {
|
|||||||
wn_c keys publish >/dev/null 2>&1 || true
|
wn_c keys publish >/dev/null 2>&1 || true
|
||||||
sleep 3
|
sleep 3
|
||||||
local out gid
|
local out gid
|
||||||
out=$(wn_b --json groups create "Interop-12" "$A_NPUB" 2>&1 | tee -a "$LOG_FILE")
|
out=$(wn_b --json groups create "Interop-12" "$A_NPUB" 2>>"$LOG_FILE")
|
||||||
gid=$(printf '%s' "$out" | jq -r '.group_id // .mls_group_id // empty')
|
printf 'wn groups create raw output: %s\n' "$out" >>"$LOG_FILE"
|
||||||
|
gid=$(printf '%s' "$out" | jq_group_id)
|
||||||
if [[ -z "$gid" ]]; then
|
if [[ -z "$gid" ]]; then
|
||||||
fail_msg "could not create Interop-12"; record_result "12 offline catchup" fail "create failed"; return
|
fail_msg "could not create Interop-12"; record_result "12 offline catchup" fail "create failed"; return
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user