Files
chains/graphvm/handler_mount_test.go
zeekayandHanzo Dev 17bdadba30 chain routes: /v1/bc -> /v1/chain
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]>
2026-09-01 08:19:10 -07:00

36 lines
1.1 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package graphvm
import (
"context"
"net/http"
"net/http/httptest"
"testing"
)
// The node mounts each CreateHandlers key at /v1/chain/<chainID>+key and matches
// that path EXACTLY, then hands the handler the request on the path it arrived
// on. A handler that dispatches on r.URL.Path is therefore unreachable.
func TestHandlersAnswerAtTheMountedPath(t *testing.T) {
const base = "/v1/chain/24C9zm36x43T7LqcaKF1ikHxSeuQeTXnstzi5Gwh2apo18rXNE"
handlers, err := (&VM{}).CreateHandlers(context.Background())
if err != nil {
t.Fatalf("CreateHandlers: %v", err)
}
if len(handlers) == 0 {
t.Fatal("CreateHandlers returned no handlers")
}
for endpoint, h := range handlers {
rec := httptest.NewRecorder()
h.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, base+endpoint, nil))
if rec.Code == http.StatusNotFound {
t.Errorf("GET %s%s: 404 — the handler dispatches on the request path instead of answering at its mount",
base, endpoint)
}
}
}