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.
90 lines
2.4 KiB
Go
90 lines
2.4 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package txs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
const defaultWeight = 10000
|
|
|
|
func TestBoundedBy(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
nodeID := ids.GenerateTestNodeID()
|
|
|
|
// case 1: a starts, a finishes, b starts, b finishes
|
|
aStartTime := uint64(0)
|
|
aEndTIme := uint64(1)
|
|
a := &Validator{
|
|
NodeID: nodeID,
|
|
Start: aStartTime,
|
|
End: aEndTIme,
|
|
Wght: defaultWeight,
|
|
}
|
|
|
|
bStartTime := uint64(2)
|
|
bEndTime := uint64(3)
|
|
b := &Validator{
|
|
NodeID: nodeID,
|
|
Start: bStartTime,
|
|
End: bEndTime,
|
|
Wght: defaultWeight,
|
|
}
|
|
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.False(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 2: a starts, b starts, a finishes, b finishes
|
|
a.Start = 0
|
|
b.Start = 1
|
|
a.End = 2
|
|
b.End = 3
|
|
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.False(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 3: a starts, b starts, b finishes, a finishes
|
|
a.Start = 0
|
|
b.Start = 1
|
|
b.End = 2
|
|
a.End = 3
|
|
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.True(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 4: b starts, a starts, a finishes, b finishes
|
|
b.Start = 0
|
|
a.Start = 1
|
|
a.End = 2
|
|
b.End = 3
|
|
require.True(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.False(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 5: b starts, b finishes, a starts, a finishes
|
|
b.Start = 0
|
|
b.End = 1
|
|
a.Start = 2
|
|
a.End = 3
|
|
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.False(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 6: b starts, a starts, b finishes, a finishes
|
|
b.Start = 0
|
|
a.Start = 1
|
|
b.End = 2
|
|
a.End = 3
|
|
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.False(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
|
|
// case 3: a starts, b starts, b finishes, a finishes
|
|
a.Start = 0
|
|
b.Start = 0
|
|
b.End = 1
|
|
a.End = 1
|
|
require.True(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
|
|
require.True(BoundedBy(b.StartTime(), b.EndTime(), a.StartTime(), a.EndTime()))
|
|
}
|