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

119 lines
2.8 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package block
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/luxfi/constants"
"github.com/luxfi/crypto/secp256k1"
"github.com/luxfi/ids"
"github.com/luxfi/node/vms/xvm/fxs"
"github.com/luxfi/node/vms/xvm/txs"
lux "github.com/luxfi/utxo"
"github.com/luxfi/utxo/secp256k1fx"
)
var (
chainID = ids.GenerateTestID()
keys = secp256k1.TestKeys()
assetID = ids.GenerateTestID()
)
func TestInvalidBlock(t *testing.T) {
require := require.New(t)
parser, err := NewParser(
[]fxs.Fx{
&secp256k1fx.Fx{},
},
)
require.NoError(err)
_, err = parser.ParseBlock(nil)
require.Error(err)
}
func TestStandardBlocks(t *testing.T) {
// check standard block can be built and parsed
require := require.New(t)
parser, err := NewParser(
[]fxs.Fx{
&secp256k1fx.Fx{},
},
)
require.NoError(err)
blkTimestamp := time.Now()
parentID := ids.GenerateTestID()
height := uint64(2022)
txs, err := createTestTxs()
require.NoError(err)
standardBlk, err := NewStandardBlock(parentID, height, blkTimestamp, txs)
require.NoError(err)
// parse block
parsed, err := parser.ParseBlock(standardBlk.Bytes())
require.NoError(err)
// compare content
require.Equal(standardBlk.ID(), parsed.ID())
require.Equal(standardBlk.Parent(), parsed.Parent())
require.Equal(standardBlk.Height(), parsed.Height())
require.Equal(standardBlk.Bytes(), parsed.Bytes())
require.Equal(standardBlk.Timestamp(), parsed.Timestamp())
require.IsType(&StandardBlock{}, parsed)
parsedStandardBlk := parsed.(*StandardBlock)
require.Equal(txs, parsedStandardBlk.Txs())
require.Equal(parsed.Txs(), parsedStandardBlk.Txs())
}
func createTestTxs() ([]*txs.Tx, error) {
countTxs := 1
testTxs := make([]*txs.Tx, 0, countTxs)
for i := 0; i < countTxs; i++ {
// Create the tx
tx := &txs.Tx{Unsigned: &txs.BaseTx{BaseTx: lux.BaseTx{
NetworkID: constants.UnitTestID,
BlockchainID: chainID,
Outs: []*lux.TransferableOutput{{
Asset: lux.Asset{ID: assetID},
Out: &secp256k1fx.TransferOutput{
Amt: uint64(12345),
OutputOwners: secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{keys[0].PublicKey().Address()},
},
},
}},
Ins: []*lux.TransferableInput{{
UTXOID: lux.UTXOID{
TxID: ids.ID{'t', 'x', 'I', 'D'},
OutputIndex: 1,
},
Asset: lux.Asset{ID: assetID},
In: &secp256k1fx.TransferInput{
Amt: uint64(54321),
Input: secp256k1fx.Input{
SigIndices: []uint32{2},
},
},
}},
Memo: []byte{1, 2, 3, 4, 5, 6, 7, 8},
}}}
if err := tx.SignSECP256K1Fx([][]*secp256k1.PrivateKey{{keys[0]}}); err != nil {
return nil, err
}
testTxs = append(testTxs, tx)
}
return testTxs, nil
}