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.
73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
//go:build skip
|
|
|
|
package platformvm
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/constants"
|
|
validators "github.com/luxfi/validators"
|
|
|
|
"github.com/luxfi/node/vms/platformvm/genesis/genesistest"
|
|
|
|
pchainapi "github.com/luxfi/node/vms/platformvm/api"
|
|
)
|
|
|
|
// TestGetAllValidatorsAt tests the GetAllValidatorsAt RPC endpoint
|
|
func TestGetAllValidatorsAt(t *testing.T) {
|
|
require := require.New(t)
|
|
service, _ := defaultService(t)
|
|
|
|
genesis := genesistest.New(t, genesistest.Config{})
|
|
|
|
args := GetAllValidatorsAtArgs{}
|
|
response := GetAllValidatorsAtReply{}
|
|
|
|
service.vm.rt.Lock.Lock()
|
|
lastAccepted := service.vm.manager.LastAccepted()
|
|
lastAcceptedBlk, err := service.vm.manager.GetBlock(lastAccepted)
|
|
require.NoError(err)
|
|
service.vm.rt.Lock.Unlock()
|
|
|
|
// Test at genesis height
|
|
args.Height = pchainapi.Height(lastAcceptedBlk.Height())
|
|
require.NoError(service.GetAllValidatorsAt(&http.Request{}, &args, &response))
|
|
|
|
// Should have at least the primary network
|
|
require.NotNil(response.ValidatorSets)
|
|
require.Len(primarySet(t, response), len(genesis.Validators))
|
|
|
|
// Test with proposed height
|
|
args.Height = pchainapi.Height(pchainapi.ProposedHeight)
|
|
require.NoError(service.GetAllValidatorsAt(context.WithValue(context.Background(), struct{}{}, "test"), &args, &response))
|
|
require.NotNil(primarySet(t, response))
|
|
|
|
// Verify each validator set has proper structure
|
|
for _, set := range response.ValidatorSets {
|
|
require.NotNil(set.Validators, "validator set for net %s should not be nil", set.ChainID)
|
|
for _, validator := range set.Validators {
|
|
require.NotZero(validator.Weight, "validator weight should not be zero")
|
|
}
|
|
}
|
|
}
|
|
|
|
// primarySet is the primary network's entry, which the reply carries as one
|
|
// element of a list rather than as a map lookup.
|
|
func primarySet(t *testing.T, reply GetAllValidatorsAtReply) []*validators.GetValidatorOutput {
|
|
t.Helper()
|
|
for _, set := range reply.ValidatorSets {
|
|
if set.ChainID == constants.PrimaryNetworkID {
|
|
return set.Validators
|
|
}
|
|
}
|
|
require.FailNow(t, "the primary network is missing from the reply")
|
|
return nil
|
|
}
|