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

71 lines
1.5 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package network
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/consensus/config"
"github.com/luxfi/ids"
"github.com/luxfi/math/set"
)
var validParameters = config.Parameters{
K: 1,
Alpha: 0.8, // Required for validation
Beta: 1,
AlphaPreference: 1,
AlphaConfidence: 1,
BetaVirtuous: 1,
BetaRogue: 1,
ConcurrentPolls: 1,
OptimalProcessing: 1,
MaxOutstandingItems: 1,
MaxItemProcessingTime: 1,
}
func TestValid(t *testing.T) {
tests := []struct {
name string
s Config
expectedErr error
}{
{
name: "invalid consensus parameters",
s: Config{
ConsensusParameters: config.Parameters{
K: 2,
AlphaPreference: 1,
},
},
expectedErr: config.ErrParametersInvalid,
},
{
name: "invalid allowed node IDs",
s: Config{
AllowedNodes: set.Of(ids.GenerateTestNodeID()),
ValidatorOnly: false,
ConsensusParameters: validParameters,
},
expectedErr: errAllowedNodesWhenNotValidatorOnly,
},
{
name: "valid",
s: Config{
ConsensusParameters: validParameters,
ValidatorOnly: false,
},
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.s.Valid()
require.ErrorIs(t, err, tt.expectedErr)
})
}
}