Files
zeekayandHanzo Dev 4b18e04aac Ask the node for /v1/chain, the only chain prefix it still serves
The node moved every chain route from /v1/bc/<alias> to /v1/chain/<alias> and
deleted the old prefix, so every call this SDK made against a current node was
a 404. The segment is constants.ChainAliasPrefix, which went from "bc" to
"chain" in luxfi/constants v1.6.4.

Call sites that already went through constants.Chain moved with the pin. These
nine spelled the prefix out longhand instead of asking the composer, so they
stayed behind: five endpoint helpers in models, the default APIEndpoint in
config, the two URLs ux prints, and two doc examples that would have sent a
reader at a deleted route.

The wallet's test double mounted /v1/bc/P and /v1/bc/X, so it answered the
route the node had dropped and would have gone on passing against a node that
no longer exists. It now serves what the node serves, and the assertion that
the SDK must not touch X in P-only mode checks the live path -- against the old
one it could never fire again.

That file has not compiled since the X/C opt-in decomplect removed
isXChainNotEnabled, so none of these tests were running. Its test went with the
function it covered.

Chain() no longer claims the node answers both spellings. It does not.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-30 15:00:58 -07:00

47 lines
1.6 KiB
Go

// Copyright (C) 2022, Lux Industries Inc All rights reserved.
// See the file LICENSE for licensing terms.
package constants
import (
"strings"
"testing"
)
// TestChainIsTheSegmentTheNodeServes pins the single segment every chain call
// hangs off. The node moved it from "bc" to "chain" and DELETED "bc", so a
// composer still spelling the old one 404s on every chain call there is.
// Reading luxconstants.ChainAliasPrefix is what carries this SDK across that
// move; this test is what proves it arrived.
func TestChainIsTheSegmentTheNodeServes(t *testing.T) {
const uri = "http://localhost:9650"
for _, alias := range []string{"P", "X", "C"} {
got := Chain(uri, alias)
if want := uri + "/v1/chain/" + alias; got != want {
t.Fatalf("Chain(%q) = %q, want %q", alias, got, want)
}
if !strings.Contains(got, "/v1/chain/") {
t.Fatalf("Chain(%q) = %q: missing the /v1/chain/ prefix the node serves", alias, got)
}
if strings.Contains(got, "/v1/bc") {
t.Fatalf("Chain(%q) = %q: still carries /v1/bc, which the node deleted", alias, got)
}
}
}
// TestChainRPCIsTheAddressCallersDial covers the composition every RPC caller
// actually builds -- the chain address plus /rpc -- because that, and not the
// bare chain address, is what a 404 shows up on.
func TestChainRPCIsTheAddressCallersDial(t *testing.T) {
got := Chain("http://localhost:9650", "C") + "/rpc"
if want := "http://localhost:9650/v1/chain/C/rpc"; got != want {
t.Fatalf("C-Chain RPC address = %q, want %q", got, want)
}
if strings.Contains(got, "/v1/bc") {
t.Fatalf("C-Chain RPC address = %q: still carries the deleted /v1/bc", got)
}
}