Files
zeekay 43e25fef7f cli: lux dev start --build-tags dchain + --plugin-dir selector
Prefer the dchain-tagged luxd build output (node/build/luxd) before PATH/config so a public
(no-D-Chain) luxd is never picked silently; default --plugin-dir to ~/.lux/plugins/current.
Default (no --build-tags) path byte-for-byte unchanged. hasBuildTag/resolvePluginDir tested.
NOTE: repo-wide lux binary has a PRE-EXISTING unrelated build break (pkg/blockchain/helper.go:116,
luxfi/api<->p2p drift) — not introduced here; devcmd pkg builds+tests clean in isolation.
2026-06-17 17:26:17 -07:00

57 lines
1.7 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package devcmd
import (
"path/filepath"
"testing"
"github.com/luxfi/constants"
)
func TestHasBuildTag(t *testing.T) {
cases := []struct {
tags string
tag string
want bool
}{
{"", "dchain", false},
{"dchain", "dchain", true},
{" dchain ", "dchain", true}, // surrounding space trimmed
{"foo,dchain", "dchain", true}, // multi-tag
{"dchain,foo", "dchain", true}, // multi-tag, first
{"foo, dchain , bar", "dchain", true}, // spaced multi-tag
{"dchains", "dchain", false}, // no substring match
{"foo,bar", "dchain", false},
}
for _, c := range cases {
if got := hasBuildTag(c.tags, c.tag); got != c.want {
t.Errorf("hasBuildTag(%q, %q) = %v, want %v", c.tags, c.tag, got, c.want)
}
}
}
func TestResolvePluginDir(t *testing.T) {
const base = "/home/u/.lux"
want := filepath.Join(base, constants.PluginsDir, "current")
// Explicit always wins, dchain or not.
if got := resolvePluginDir("/custom/plugins", base, true); got != "/custom/plugins" {
t.Errorf("explicit+dchain = %q, want /custom/plugins", got)
}
if got := resolvePluginDir("/custom/plugins", base, false); got != "/custom/plugins" {
t.Errorf("explicit+nodchain = %q, want /custom/plugins", got)
}
// dchain with no explicit -> ~/.lux/plugins/current (deterministic EVM plugin).
if got := resolvePluginDir("", base, true); got != want {
t.Errorf("dchain default = %q, want %q", got, want)
}
// non-dchain with no explicit -> "" (luxd uses its own default, unchanged).
if got := resolvePluginDir("", base, false); got != "" {
t.Errorf("non-dchain default = %q, want empty", got)
}
}