mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
test(genesis/builder): canonical evmAddr/utxoAddr fixture parse gate (#121)
Add TestCanonicalGenesisFixtureParses — loads the canonical mainnet genesis.json (genesis v1.12.19 evmAddr/utxoAddr field names) through genesiscfg.GetConfigFile and asserts EVMAddr/UTXOAddr decode to non-zero ids.ShortID values. This is the "have we adopted the rename" gate — if the loader silently swallows the new field names (e.g. via a regression to ethAddr/luxAddr struct tags), every allocation Address comes back as ShortEmpty and the assertion catches it before that ships. Test is host-path aware: skips when ~/work/lux/genesis is not on disk (CI without sibling checkout), runs when it is.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package builder
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
genesiscfg "github.com/luxfi/genesis/pkg/genesis"
|
||||
)
|
||||
|
||||
// TestCanonicalGenesisFixtureParses confirms the canonical mainnet genesis.json
|
||||
// (evmAddr/utxoAddr field names per genesis v1.12.19) parses cleanly via
|
||||
// GetConfigFile and produces non-zero EVMAddr / UTXOAddr values.
|
||||
//
|
||||
// This is the "have we adopted the rename" gate — if the loader rejects
|
||||
// the canonical fixture, the API rename did not land.
|
||||
func TestCanonicalGenesisFixtureParses(t *testing.T) {
|
||||
candidates := []string{
|
||||
filepath.Join(os.Getenv("HOME"), "work/lux/genesis/configs/mainnet/genesis.json"),
|
||||
"../../../genesis/configs/mainnet/genesis.json",
|
||||
}
|
||||
|
||||
var path string
|
||||
for _, p := range candidates {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
path = p
|
||||
break
|
||||
}
|
||||
}
|
||||
if path == "" {
|
||||
t.Skip("canonical mainnet genesis fixture not on disk; skipping")
|
||||
}
|
||||
|
||||
cfg, err := genesiscfg.GetConfigFile(path)
|
||||
require.NoError(t, err, "canonical fixture must parse with v1.12.19 evmAddr/utxoAddr names")
|
||||
require.NotEmpty(t, cfg.Allocations, "fixture has no allocations")
|
||||
|
||||
for i, a := range cfg.Allocations {
|
||||
require.NotEqual(t, ids.ShortEmpty, a.EVMAddr, "allocation[%d] EVMAddr is zero — parse silently dropped", i)
|
||||
require.NotEqual(t, ids.ShortEmpty, a.UTXOAddr, "allocation[%d] UTXOAddr is zero — parse silently dropped", i)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user