Files
zeekayandHanzo Dev 37e2940ead mesh is the peer layer, network is the validator set
Two packages were named for the same word and meant different things. network/
dialed peers, exchanged keys, throttled and tracked them; nets/ tracked which
chains share a validator set and when they have all bootstrapped. One letter
apart, and neither name said which was which.

The peer layer is mesh — the word this estate already uses for it, in
lux-rs/node's own mesh.rs. That frees network for the thing that is actually a
network: a set of chains sharing a validator set. A network holds chains; a
chain belongs to one network.

github.com/luxfi/p2p stays what it is, the gossip library the VMs use. Three
concerns, three names, none of them borrowed from another.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-07 21:17:09 -07:00

66 lines
2.0 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package poa
import (
"testing"
"time"
"github.com/stretchr/testify/require"
consensusconfig "github.com/luxfi/consensus/config"
"github.com/luxfi/node/config"
"github.com/luxfi/node/network"
)
func TestPOAConsensusParameters(t *testing.T) {
require := require.New(t)
// Test that POA consensus parameters are correctly set
params := network.GetPOAConsensusParameters()
// POA mode should have K=1, Alpha=1, Beta=1 for single-node operation
require.Equal(1, params.K, "POA mode should have K=1")
require.Equal(1, params.AlphaPreference, "POA mode should have AlphaPreference=1")
require.Equal(1, params.AlphaConfidence, "POA mode should have AlphaConfidence=1")
require.Equal(uint32(1), params.Beta, "POA mode should have Beta=1")
require.Equal(1, params.ConcurrentPolls, "POA mode should have ConcurrentPolls=1")
}
func TestPOANetConfig(t *testing.T) {
require := require.New(t)
// Test net config with POA enabled
cfg := network.Config{
POAEnabled: true,
POASingleNodeMode: true,
POAMinBlockTime: 1 * time.Second,
ConsensusParameters: consensusconfig.Parameters{
K: 1,
Alpha: 0.69, // Must be between 0.68 and 1.0
AlphaPreference: 1,
AlphaConfidence: 1,
Beta: uint32(1),
ConcurrentPolls: 1,
OptimalProcessing: 10,
MaxOutstandingItems: 256,
MaxItemProcessingTime: 30 * time.Second,
},
}
// Verify configuration is valid
err := cfg.Valid()
require.NoError(err, "POA net config should be valid")
}
func TestPOAConfigKeys(t *testing.T) {
require := require.New(t)
// Test that POA configuration keys are defined
require.Equal("poa-mode-enabled", config.POAModeEnabledKey)
require.Equal("poa-single-node-mode", config.POASingleNodeModeKey)
require.Equal("poa-min-block-time", config.POAMinBlockTimeKey)
require.Equal("poa-authorized-nodes", config.POAAuthorizedNodesKey)
}