mirror of
https://github.com/luxfi/genesis.git
synced 2026-10-30 16:25:45 +00:00
pkg/genesis.GetBootstrappers reads bootstrappers.json from ~/work/lux/genesis, ~/.lux, or /etc/lux — all dead paths inside a node container, which bakes none of them, so a containerized node resolved zero peers and never bootstrapped. The configs package already embeds mainnet/testnet/devnet/localnet (genesis bytes), so the bootstrapper lists are in the binary already; expose them via GetBootstrappers so a node finds peers with zero on-disk config. Same JSON is both the embed source and the disk seed — one source of truth. Co-authored-by: Hanzo Dev <[email protected]>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package configs
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestGetBootstrappers_EmbeddedMainnet proves the bootstrapper list travels in
|
|
// the binary via the embed — a node in a container (which bakes no
|
|
// bootstrappers.json on disk) still finds peers.
|
|
func TestGetBootstrappers_EmbeddedMainnet(t *testing.T) {
|
|
got := GetBootstrappers(MainnetID)
|
|
if len(got) == 0 {
|
|
t.Fatal("mainnet bootstrappers must resolve from the embed, got none")
|
|
}
|
|
for _, b := range got {
|
|
if !strings.HasPrefix(b.ID, "NodeID-") {
|
|
t.Errorf("bootstrapper id must be a NodeID, got %q", b.ID)
|
|
}
|
|
if !strings.Contains(b.IP, ":") {
|
|
t.Errorf("bootstrapper ip must be host:port, got %q", b.IP)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGetBootstrappers_EmbeddedTestnet(t *testing.T) {
|
|
if len(GetBootstrappers(TestnetID)) == 0 {
|
|
t.Fatal("testnet bootstrappers must resolve from the embed, got none")
|
|
}
|
|
}
|
|
|
|
// A network with no embedded list returns nil, so the caller falls back to disk
|
|
// paths or an explicit --bootstrap-nodes rather than crashing.
|
|
func TestGetBootstrappers_UnknownNetworkIsNil(t *testing.T) {
|
|
if GetBootstrappers(0xF00D) != nil {
|
|
t.Error("unknown network must return nil bootstrappers")
|
|
}
|
|
}
|