Files
node/vms/platformvm/txs/create_blockchain_test.go
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

92 lines
2.7 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package txs
import (
"testing"
"github.com/stretchr/testify/require"
consensustest "github.com/luxfi/consensus/test/helpers"
"github.com/luxfi/constants"
"github.com/luxfi/ids"
lux "github.com/luxfi/utxo"
"github.com/luxfi/utxo/secp256k1fx"
)
// TestUnsignedCreateChainTxVerify pins the CreateChainTx syntactic invariants.
// Struct-is-wire has no post-hoc field mutation, so every invalid case is built
// THROUGH the NewCreateChainTx constructor with the offending value baked in.
func TestUnsignedCreateChainTxVerify(t *testing.T) {
rt := consensustest.Runtime(t, ids.GenerateTestID())
validChain := ids.GenerateTestID()
auth := &secp256k1fx.Input{SigIndices: []uint32{0, 1}}
base := func() *lux.BaseTx {
return &lux.BaseTx{NetworkID: rt.NetworkID, BlockchainID: rt.ChainID}
}
tests := []struct {
description string
build func(t *testing.T) *CreateChainTx
expectedErr error
}{
{
description: "tx is nil",
build: func(*testing.T) *CreateChainTx { return nil },
expectedErr: ErrNilTx,
},
{
description: "vm ID is empty",
build: func(t *testing.T) *CreateChainTx {
tx, err := NewCreateChainTx(base(), validChain, "yeet", ids.Empty, nil, nil, auth)
require.NoError(t, err)
return tx
},
expectedErr: errInvalidVMID,
},
{
description: "chain ID is primary network ID",
build: func(t *testing.T) *CreateChainTx {
tx, err := NewCreateChainTx(base(), constants.PrimaryNetworkID, "yeet", constants.XVMID, nil, nil, auth)
require.NoError(t, err)
return tx
},
expectedErr: ErrCantValidatePrimaryNetwork,
},
{
description: "chain name is too long",
build: func(t *testing.T) *CreateChainTx {
tx, err := NewCreateChainTx(base(), validChain, string(make([]byte, MaxNameLen+1)), constants.XVMID, nil, nil, auth)
require.NoError(t, err)
return tx
},
expectedErr: errNameTooLong,
},
{
description: "chain name has invalid character",
build: func(t *testing.T) *CreateChainTx {
tx, err := NewCreateChainTx(base(), validChain, "⌘", constants.XVMID, nil, nil, auth)
require.NoError(t, err)
return tx
},
expectedErr: errIllegalNameCharacter,
},
{
description: "genesis data is too long",
build: func(t *testing.T) *CreateChainTx {
tx, err := NewCreateChainTx(base(), validChain, "yeet", constants.XVMID, nil, make([]byte, MaxGenesisLen+1), auth)
require.NoError(t, err)
return tx
},
expectedErr: errGenesisTooLong,
},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
require.ErrorIs(t, test.build(t).SyntacticVerify(rt), test.expectedErr)
})
}
}