mirror of
https://github.com/luxfi/explorer.git
synced 2026-09-24 00:25:12 +00:00
luxd serves chain routes under /v1/chain, and the node, cli and sdk releases already ship it. The deployed gateways still answer the old prefix, so remote reads break until they are redeployed; the estate moves together rather than sitting half converted. Lines that record an observation - a probe, a status code, a past release - keep the prefix they were written against, as do URLs on hosts that are not ours. Avalanche endpoints move to /ext/bc, which is the path that host serves. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// The SPA was being handed the address the SERVER dials. In-cluster that is a
|
|
// service-mesh name, so every browser hitting explore.lux.network got
|
|
// http://luxd-headless.lux-mainnet.svc.cluster.local:9630/v1/bc/C/rpc — a host
|
|
// it cannot resolve. RPC (what we dial) and the browser's RPC are two different
|
|
// values; this pins them apart.
|
|
func TestBrowserRPC(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
in ChainConfig
|
|
want string
|
|
}{{
|
|
name: "cluster-internal RPC is never handed to a browser",
|
|
in: ChainConfig{RPC: "http://luxd-headless.lux-mainnet.svc.cluster.local:9630/v1/chain/C/rpc"},
|
|
want: "",
|
|
}, {
|
|
name: "explicit public_rpc wins",
|
|
in: ChainConfig{
|
|
RPC: "http://luxd-headless.lux-mainnet.svc.cluster.local:9630/v1/chain/C/rpc",
|
|
PublicRPC: "https://api.lux.network/v1/chain/C/rpc",
|
|
},
|
|
want: "https://api.lux.network/v1/chain/C/rpc",
|
|
}, {
|
|
name: "already-public RPC passes through unchanged",
|
|
in: ChainConfig{RPC: "https://api.zoo.ngo/v1/chain/C/rpc"},
|
|
want: "https://api.zoo.ngo/v1/chain/C/rpc",
|
|
}, {
|
|
name: "bare service name is not public",
|
|
in: ChainConfig{RPC: "http://luxd-headless:9630/v1/chain/C/rpc"},
|
|
want: "",
|
|
}, {
|
|
name: "loopback is not public",
|
|
in: ChainConfig{RPC: "http://127.0.0.1:9630/v1/chain/C/rpc"},
|
|
want: "",
|
|
}, {
|
|
name: "RFC1918 literal is not public",
|
|
in: ChainConfig{RPC: "http://10.150.2.1:9630/v1/chain/C/rpc"},
|
|
want: "",
|
|
}, {
|
|
name: "empty stays empty",
|
|
in: ChainConfig{},
|
|
want: "",
|
|
}} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := browserRPC(tc.in); got != tc.want {
|
|
t.Fatalf("browserRPC() = %q, want %q", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|