Files
zeekay 7cf87b230b node-unified is the node
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.
2026-09-07 16:15:25 -07:00

134 lines
3.0 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package stakeable
import (
"errors"
"testing"
"github.com/luxfi/mock/gomock"
"github.com/stretchr/testify/require"
lux "github.com/luxfi/utxo"
luxmock "github.com/luxfi/utxo/luxmock"
)
var errTest = errors.New("hi mom")
func TestLockOutVerify(t *testing.T) {
tests := []struct {
name string
locktime uint64
transferableOutF func(*gomock.Controller) lux.TransferableOut
expectedErr error
}{
{
name: "happy path",
locktime: 1,
transferableOutF: func(ctrl *gomock.Controller) lux.TransferableOut {
o := luxmock.NewMockTransferableOut(ctrl)
o.EXPECT().Verify().Return(nil)
return o
},
expectedErr: nil,
},
{
name: "invalid locktime",
locktime: 0,
transferableOutF: func(*gomock.Controller) lux.TransferableOut {
return nil
},
expectedErr: errInvalidLocktime,
},
{
name: "nested",
locktime: 1,
transferableOutF: func(*gomock.Controller) lux.TransferableOut {
return &LockOut{}
},
expectedErr: errNestedStakeableLocks,
},
{
name: "inner output fails verification",
locktime: 1,
transferableOutF: func(ctrl *gomock.Controller) lux.TransferableOut {
o := luxmock.NewMockTransferableOut(ctrl)
o.EXPECT().Verify().Return(errTest)
return o
},
expectedErr: errTest,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
lockOut := &LockOut{
Locktime: tt.locktime,
TransferableOut: tt.transferableOutF(ctrl),
}
require.Equal(t, tt.expectedErr, lockOut.Verify())
})
}
}
func TestLockInVerify(t *testing.T) {
tests := []struct {
name string
locktime uint64
transferableInF func(*gomock.Controller) lux.TransferableIn
expectedErr error
}{
{
name: "happy path",
locktime: 1,
transferableInF: func(ctrl *gomock.Controller) lux.TransferableIn {
o := luxmock.NewMockTransferableIn(ctrl)
o.EXPECT().Verify().Return(nil)
return o
},
expectedErr: nil,
},
{
name: "invalid locktime",
locktime: 0,
transferableInF: func(*gomock.Controller) lux.TransferableIn {
return nil
},
expectedErr: errInvalidLocktime,
},
{
name: "nested",
locktime: 1,
transferableInF: func(*gomock.Controller) lux.TransferableIn {
return &LockIn{}
},
expectedErr: errNestedStakeableLocks,
},
{
name: "inner input fails verification",
locktime: 1,
transferableInF: func(ctrl *gomock.Controller) lux.TransferableIn {
o := luxmock.NewMockTransferableIn(ctrl)
o.EXPECT().Verify().Return(errTest)
return o
},
expectedErr: errTest,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
lockOut := &LockIn{
Locktime: tt.locktime,
TransferableIn: tt.transferableInF(ctrl),
}
require.Equal(t, tt.expectedErr, lockOut.Verify())
})
}
}