Skip to content

Commit be48daf

Browse files
committed
Use direct local addresses for Iroh integration fixtures
1 parent 3a2249f commit be48daf

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎test/run_iroh_integration.sh‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,21 @@ PYTHONPATH="$VGI_RPC_PYTHON_DIR" \
9090
PIDS+=("$!")
9191
RAW_PORT="$(wait_for_value "$RUN_DIR/raw-worker.log" 's/^TCP:127\.0\.0\.1:\([0-9][0-9]*\)$/\1/p')"
9292

93-
"$VGI_IROH_BRIDGE_BIN" --ephemeral --http-upstream "http://127.0.0.1:$HTTP_PORT" \
93+
# Both endpoints run on this host. Supply their addresses explicitly so this
94+
# qualification does not race public discovery or depend on relay availability.
95+
"$VGI_IROH_BRIDGE_BIN" --ephemeral --no-relay --print-direct-addresses \
96+
--http-upstream "http://127.0.0.1:$HTTP_PORT" \
9497
>"$RUN_DIR/http-bridge.log" 2>&1 &
9598
PIDS+=("$!")
9699
HTTP_ENDPOINT="$(wait_for_value "$RUN_DIR/http-bridge.log" '/^[0-9a-f][0-9a-f]*$/p')"
100+
HTTP_ADDRESS="$(wait_for_value "$RUN_DIR/http-bridge.log" 's/^DIRECT://p')"
97101

98-
"$VGI_IROH_BRIDGE_BIN" --ephemeral --raw-upstream "tcp://127.0.0.1:$RAW_PORT" \
102+
"$VGI_IROH_BRIDGE_BIN" --ephemeral --no-relay --print-direct-addresses \
103+
--raw-upstream "tcp://127.0.0.1:$RAW_PORT" \
99104
>"$RUN_DIR/raw-bridge.log" 2>&1 &
100105
PIDS+=("$!")
101106
RAW_ENDPOINT="$(wait_for_value "$RUN_DIR/raw-bridge.log" '/^[0-9a-f][0-9a-f]*$/p')"
107+
RAW_ADDRESS="$(wait_for_value "$RUN_DIR/raw-bridge.log" 's/^DIRECT://p')"
102108

103109
if [[ ${#HTTP_ENDPOINT} -ne 64 || ${#RAW_ENDPOINT} -ne 64 ]]; then
104110
echo "bridge emitted an invalid EndpointId" >&2
@@ -108,12 +114,12 @@ fi
108114
HTTP_RESULT="$($HAYBARN :memory: -csv -noheader -c "
109115
SET vgi_iroh_connect_timeout_seconds = 7;
110116
SET vgi_iroh_io_timeout_seconds = 19;
111-
ATTACH 'example' AS remote_a (TYPE vgi, LOCATION 'httpi://${HTTP_ENDPOINT}');
117+
ATTACH 'example' AS remote_a (TYPE vgi, LOCATION 'httpi://${HTTP_ENDPOINT}', IROH_NO_RELAY true, IROH_DIRECT_ADDRESSES ['${HTTP_ADDRESS}']);
112118
SELECT remote_a.main.double(21);
113119
SELECT remote_a.main.whoami(1);
114120
SET vgi_iroh_connect_timeout_seconds = 11;
115121
SET vgi_iroh_io_timeout_seconds = 23;
116-
ATTACH 'example' AS remote_b (TYPE vgi, LOCATION 'httpi://${HTTP_ENDPOINT}');
122+
ATTACH 'example' AS remote_b (TYPE vgi, LOCATION 'httpi://${HTTP_ENDPOINT}', IROH_NO_RELAY true, IROH_DIRECT_ADDRESSES ['${HTTP_ADDRESS}']);
117123
SELECT remote_b.main.whoami(1);
118124
")"
119125
grep -Fxq '42' <<<"$HTTP_RESULT"
@@ -126,23 +132,22 @@ if [[ "$(wc -l <<<"$HTTP_PRINCIPALS" | tr -d ' ')" != "2" ]] || \
126132
fi
127133

128134
RAW_RESULT="$($HAYBARN :memory: -csv -noheader -c "
129-
ATTACH 'example' AS remote (TYPE vgi, LOCATION 'iroh://${RAW_ENDPOINT}');
135+
ATTACH 'example' AS remote (TYPE vgi, LOCATION 'iroh://${RAW_ENDPOINT}', IROH_NO_RELAY true, IROH_DIRECT_ADDRESSES ['${RAW_ADDRESS}']);
130136
SELECT remote.main.double(21);
131137
SELECT sum(i) FROM remote.main.sequence(10000) t(i);
132138
")"
133139
grep -Fxq '42' <<<"$RAW_RESULT"
134140
grep -Fxq '49995000' <<<"$RAW_RESULT"
135141

136-
# vgi_catalogs() builds the same default Iroh configuration ATTACH does (no
137-
# options: scoped TYPE iroh secret, else an ephemeral identity), so discovery
138-
# works over both Iroh transports without an ATTACH. The named iroh_* options
139-
# mirror ATTACH's.
142+
# vgi_catalogs() resolves identities the same way ATTACH does (scoped TYPE iroh
143+
# secret, else an ephemeral identity). Exercise both transports without an
144+
# ATTACH, including relay options with an explicit direct destination.
140145
CATALOGS_RESULT="$($HAYBARN :memory: -csv -noheader -c "
141-
SELECT 'raw', catalog FROM vgi_catalogs('iroh://${RAW_ENDPOINT}');
142-
SELECT 'http', catalog FROM vgi_catalogs('httpi://${HTTP_ENDPOINT}');
143-
SELECT 'http_opts', catalog FROM vgi_catalogs('httpi://${HTTP_ENDPOINT}', iroh_no_relay := false, iroh_relay_urls := []);
146+
SELECT 'raw', catalog FROM vgi_catalogs('iroh://${RAW_ENDPOINT}', iroh_no_relay := true, iroh_direct_addresses := ['${RAW_ADDRESS}']);
147+
SELECT 'http', catalog FROM vgi_catalogs('httpi://${HTTP_ENDPOINT}', iroh_no_relay := true, iroh_direct_addresses := ['${HTTP_ADDRESS}']);
148+
SELECT 'http_opts', catalog FROM vgi_catalogs('httpi://${HTTP_ENDPOINT}', iroh_no_relay := false, iroh_relay_urls := [], iroh_direct_addresses := ['${HTTP_ADDRESS}']);
144149
CREATE SECRET iroh_raw (TYPE iroh, SCOPE 'iroh://${RAW_ENDPOINT}', SECRET_KEY '$(printf '%064x' 7)');
145-
SELECT 'raw_secret', catalog FROM vgi_catalogs('iroh://${RAW_ENDPOINT}');
150+
SELECT 'raw_secret', catalog FROM vgi_catalogs('iroh://${RAW_ENDPOINT}', iroh_no_relay := true, iroh_direct_addresses := ['${RAW_ADDRESS}']);
146151
")"
147152
for label in raw http http_opts raw_secret; do
148153
if ! grep -Fxq "${label},example" <<<"$CATALOGS_RESULT"; then

0 commit comments

Comments
 (0)