mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
The module already called itself github.com/luxfi/node while containing no node in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and the Go column of the matrix measured a VM plugin. A repo that fetches the thing it claims to be has not replaced it, so the Go sources move in — 1515 files, the daemon and everything under it — and the build reaches outside this module for nothing. Rust and C++ sit beside it unchanged and are still measured against it by the differential. That is the point of one repo: the reference implementation and the two ports are the same checkout, so parity is a thing you can run rather than a thing you assert. Verified: builds, and the closure carries no lux-private — checked at build time rather than believed. The daemon starts twelve chains on a local network (P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
51 lines
1.8 KiB
Go
51 lines
1.8 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/spf13/pflag"
|
|
"github.com/spf13/viper"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestChainsDefaultsEmpty pins the consent contract: a node runs no
|
|
// consent-requiring chain unless its operator names one. The default has to be
|
|
// empty rather than "everything in genesis", because the chains behind it cost
|
|
// an operator something validating the primary network did not ask for — a
|
|
// matcher to sit beside, an HSM, a GPU, a custody role — and a default that
|
|
// opts every validator into those is a default nobody chose.
|
|
func TestChainsDefaultsEmpty(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
fs := BuildFlagSet()
|
|
flag := fs.Lookup(ChainsKey)
|
|
require.NotNil(flag, "chains flag must be registered")
|
|
|
|
v := viper.New()
|
|
require.NoError(v.BindPFlags(fs))
|
|
require.Empty(v.GetStringSlice(ChainsKey), "chains must read empty by default")
|
|
|
|
v.Set(ChainsKey, []string{"D", "B", "M"})
|
|
require.Equal([]string{"D", "B", "M"}, v.GetStringSlice(ChainsKey))
|
|
}
|
|
|
|
// TestChainsTakesAListNotABool is the regression lock on the shape. The opt-in
|
|
// was a bool named for ONE chain, which answered the question for that chain
|
|
// and left the next one to add a second flag, a second config field and a
|
|
// second branch that could disagree with the first. One list, any number of
|
|
// chains, one rule reading it.
|
|
func TestChainsTakesAListNotABool(t *testing.T) {
|
|
fs := BuildFlagSet()
|
|
flag := fs.Lookup(ChainsKey)
|
|
require.NotNil(t, flag)
|
|
require.Equal(t, "stringSlice", flag.Value.Type(),
|
|
"consent must be a list of chains, not a per-chain boolean")
|
|
|
|
var missing *pflag.Flag
|
|
require.Equal(t, missing, fs.Lookup("dex-validator"),
|
|
"the per-chain boolean must be gone, not shadowed by the list")
|
|
}
|