mirror of
https://github.com/luxfi/sdk.git
synced 2026-10-30 15:19:23 +00:00
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]>
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
// Copyright (C) 2022, Lux Industries Inc All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package models
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestEndpointsAreTheRoutesTheNodeServes pins the endpoint helpers to the
|
|
// node's live chain prefix. These five spelled /v1/bc out longhand instead of
|
|
// asking the composer, so they kept 404ing after the node deleted that prefix
|
|
// -- the drift a literal invites and a composer cannot have.
|
|
func TestEndpointsAreTheRoutesTheNodeServes(t *testing.T) {
|
|
const base = "http://localhost:9650"
|
|
|
|
for name, got := range map[string]string{
|
|
"GetRPCEndpoint": GetRPCEndpoint(base, "C"),
|
|
"GetWSEndpoint": GetWSEndpoint(base, "C"),
|
|
"CChainEndpoint": Local.CChainEndpoint(),
|
|
"BlockchainEndpoint": Local.BlockchainEndpoint("2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM"),
|
|
"BlockchainEndpointC": Local.BlockchainEndpoint(""),
|
|
} {
|
|
if !strings.Contains(got, "/v1/chain/") {
|
|
t.Errorf("%s = %q: missing the /v1/chain/ prefix the node serves", name, got)
|
|
}
|
|
if strings.Contains(got, "/v1/bc") {
|
|
t.Errorf("%s = %q: still carries /v1/bc, which the node deleted", name, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestWSEndpointKeepsItsScheme guards the one helper whose suffix is not /rpc:
|
|
// composing the chain address must not quietly turn a socket into an RPC call.
|
|
func TestWSEndpointKeepsItsScheme(t *testing.T) {
|
|
got := GetWSEndpoint("http://localhost:9650", "C")
|
|
|
|
if want := "http://localhost:9650/v1/chain/C/ws"; got != want {
|
|
t.Fatalf("GetWSEndpoint = %q, want %q", got, want)
|
|
}
|
|
}
|