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

69 lines
1.7 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build test
package merkledb
import (
"io"
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/container/maybe"
)
func Test_Node_Marshal(t *testing.T) {
root := newNode(Key{})
require.NotNil(t, root)
fullKey := ToKey([]byte("key"))
childNode := newNode(fullKey)
root.addChild(childNode, 4)
childNode.setValue(DefaultHasher, maybe.Some([]byte("value")))
require.NotNil(t, childNode)
root.addChild(childNode, 4)
data := root.bytes()
rootParsed, err := parseNode(DefaultHasher, ToKey([]byte("")), data)
require.NoError(t, err)
require.Len(t, rootParsed.children, 1)
rootIndex := getSingleChildKey(root, 4).Token(0, 4)
parsedIndex := getSingleChildKey(rootParsed, 4).Token(0, 4)
rootChildEntry := root.children[rootIndex]
parseChildEntry := rootParsed.children[parsedIndex]
require.Equal(t, rootChildEntry.id, parseChildEntry.id)
}
func Test_Node_Marshal_Errors(t *testing.T) {
root := newNode(Key{})
require.NotNil(t, root)
fullKey := ToKey([]byte{255})
childNode1 := newNode(fullKey)
root.addChild(childNode1, 4)
childNode1.setValue(DefaultHasher, maybe.Some([]byte("value1")))
require.NotNil(t, childNode1)
root.addChild(childNode1, 4)
fullKey = ToKey([]byte{237})
childNode2 := newNode(fullKey)
root.addChild(childNode2, 4)
childNode2.setValue(DefaultHasher, maybe.Some([]byte("value2")))
require.NotNil(t, childNode2)
root.addChild(childNode2, 4)
data := root.bytes()
for i := 1; i < len(data); i++ {
broken := data[:i]
_, err := parseNode(DefaultHasher, ToKey([]byte("")), broken)
require.ErrorIs(t, err, io.ErrUnexpectedEOF)
}
}