Files
zeekay 299b9230bc A validator answer states its own ZAP wire
NodeID is [20]byte and TxID is [32]byte, and the derived codec refuses a
fixed array outright, so getValidatorsAt could not cross the op-call plane
at all. zap_gen.go is generated by zip.Codecs from the same layout the
plane encodes against.

go.sum was missing entries for this module own direct imports, so nothing
here built; go mod tidy records them.
2026-08-29 18:58:36 -07:00

36 lines
947 B
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package validators
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/ids"
)
// A validator answer carries two ids — a NodeID is [20]byte and a TxID is
// [32]byte — and a DERIVED codec refuses a fixed array outright. zap_gen.go is
// why getValidatorsAt can cross the plane at all; this is that both ids and the
// keys beside them arrive whole.
func TestTheIDsSurviveTheWire(t *testing.T) {
require := require.New(t)
sent := GetValidatorOutput{
NodeID: ids.NodeID{0: 0xab, 19: 0xcd},
PublicKey: []byte{1, 2, 3},
CoronaPubKey: []byte{4, 5},
Light: 7,
Weight: 7,
TxID: ids.ID{0: 0xf0, 31: 0x0d},
}
enc, err := sent.MarshalZAP()
require.NoError(err)
var back GetValidatorOutput
require.NoError(back.UnmarshalZAP(enc))
require.Equal(sent, back)
}