Files
zeekayandHanzo Dev d678c2d213 transform: publish upstream simplex as luxfi/bft on luxfi/log
Reapplies the fork's whole delta on top of the merge, as one reviewable diff
rather than 43 conflict resolutions. Nothing here changes consensus behaviour.

- module github.com/luxfi/bft, Go 1.26.4; root package simplex -> bft, which
  would otherwise collide with the simplex/ subpackage under this module name.
- go.uber.org/zap -> github.com/luxfi/log, so common.Logger takes ...log.Field.
  zap.Error maps to log.Err: log.Error is luxfi/log's package-level logging
  function, not a field constructor, and the compiler is the only thing that
  catches that. Needs luxfi/log v1.6.1 for the Stringers constructor.
- avalanchego/ -> host/. The package holds NodeID, VMBlock, Bitmask and size
  limits — the host node's types, vendored to avoid importing a whole node — so
  it is named for what it holds. Renaming it luxd/ would have swapped one brand
  for another and said just as little.
- testutil/logger.go reimplemented without zapcore. Upstream layers a
  keyword-filtering Core, a debug-swallowing Encoder and a Tee because that is
  zap's extension model; luxfi/log has no such seam, so every policy is applied
  in one emit. That also fixes two defects the layering caused:
  SilenceExceptKeywords rebuilt the logger and discarded an installed Intercept
  hook, and the two sinks read different env vars (LOG_LEVEL vs log_level) so
  they disagreed about suppressing debug. Hooks run outside the lock, so a hook
  that logs fails the test instead of deadlocking it. Fatal panics rather than
  exiting, because exiting takes the suite down with no attribution.
- simplex/monitor_test.go keeps a local logger: testutil imports simplex, so an
  internal test cannot import testutil back without closing a cycle.
- README keeps the name Simplex throughout — it is the protocol's own name and
  the subject of reference [1]. Only the deployment target changed. The HyperSDK
  sentence still says Avalanche because that sentence is true.
- Drops the fork's Makefile: it duplicated unit-tests.sh and fuzz.sh, and ran the
  suite with -timeout 30s when simplex alone needs over 100s.

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

68 lines
2.2 KiB
Go

// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package testutil
import (
"testing"
"github.com/luxfi/bft/common"
"github.com/stretchr/testify/require"
)
// NewEmptyNotarization creates a new empty notarization
func NewEmptyNotarization(nodes []common.NodeID, round uint64) *common.EmptyNotarization {
var qc TestQC
for i, node := range nodes {
qc = append(qc, common.Signature{Signer: node, Value: []byte{byte(i)}})
}
return &common.EmptyNotarization{
QC: qc,
Vote: common.ToBeSignedEmptyVote{EmptyVoteMetadata: common.EmptyVoteMetadata{
Round: round,
}},
}
}
func NewNotarization(logger common.Logger, signatureAggregator common.SignatureAggregator, block common.VerifiedBlock, ids []common.NodeID) (common.Notarization, error) {
votesForCurrentRound := make(map[string]*common.Vote)
for _, id := range ids {
vote, err := NewTestVote(block, id)
if err != nil {
return common.Notarization{}, err
}
votesForCurrentRound[string(id)] = vote
}
notarization, err := common.NewNotarization(logger, signatureAggregator, votesForCurrentRound, block.BlockHeader())
return notarization, err
}
func NewNotarizationRecord(logger common.Logger, signatureAggregator common.SignatureAggregator, block common.VerifiedBlock, ids []common.NodeID) ([]byte, error) {
notarization, err := NewNotarization(logger, signatureAggregator, block, ids)
if err != nil {
return nil, err
}
record := common.NewQuorumRecord(notarization.QC.Bytes(), notarization.Vote.Bytes(), common.NotarizationRecordType)
return record, nil
}
// creates a new finalization
func NewFinalizationRecord(t *testing.T, signatureAggregator common.SignatureAggregator, block common.VerifiedBlock, ids []common.NodeID) (common.Finalization, []byte) {
finalizations := make([]*common.FinalizeVote, len(ids))
for i, id := range ids {
finalizations[i] = NewTestFinalizeVote(t, block, id)
}
finalization, err := common.NewFinalization(signatureAggregator, finalizations)
require.NoError(t, err)
record := common.NewQuorumRecord(finalization.QC.Bytes(), finalization.Finalization.Bytes(), common.FinalizationRecordType)
return finalization, record
}