Files
zeekay 8f56009cc7 fix: deep audit - remove stubs, fix imports, clean dead code
Deep audit changes:
- Replace stub signature aggregator with real SDK warp implementation
- Remove dead pkg/lpm package (SDK lpmintegration used instead)
- Fix fs imports: use local utils.FileExists, DirExists, ExpandHome
- Fix secp256k1fx imports: use node/vms/secp256k1fx
- Fix platformvm imports: use node/vms/platformvm
- Fix e2e test TODOs: uncomment BootstrapValidators assertions
- Improve localnet stub implementations with real logic
- Fix node.go fs.FileExists reference

Note: Build requires GOWORK=off due to workspace dependency issues
2026-01-10 11:17:00 -08:00

113 lines
2.4 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package migrations
import (
"io"
"os"
"path/filepath"
"testing"
"github.com/luxfi/cli/pkg/application"
"github.com/luxfi/cli/pkg/config"
"github.com/luxfi/cli/pkg/prompts"
"github.com/luxfi/cli/pkg/ux"
"github.com/luxfi/constants"
luxlog "github.com/luxfi/log"
"github.com/luxfi/sdk/models"
"github.com/stretchr/testify/require"
)
func TestEVMRenameMigration(t *testing.T) {
type test struct {
name string
sc *models.Sidecar
expectedVM string
}
chainName := "test"
tests := []test{
{
name: "Convert EVM",
sc: &models.Sidecar{
Name: chainName,
VM: "EVM",
},
expectedVM: "Lux EVM",
},
{
name: "Preserve Lux EVM",
sc: &models.Sidecar{
Name: chainName,
VM: "Lux EVM",
},
expectedVM: "Lux EVM",
},
{
name: "Ignore unknown",
sc: &models.Sidecar{
Name: chainName,
VM: "unknown",
},
expectedVM: "unknown",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ux.NewUserLog(luxlog.NewNoOpLogger(), io.Discard)
require := require.New(t)
testDir := t.TempDir()
app := application.New()
app.Setup(testDir, luxlog.NewNoOpLogger(), config.New(), prompts.NewPrompter(), application.NewDownloader())
err := app.CreateSidecar(tt.sc)
require.NoError(err)
runner := migrationRunner{
showMsg: true,
running: false,
migrations: map[int]migrationFunc{
0: migrateEVMNames,
},
}
// run the migration
err = runner.run(app)
require.NoError(err)
loadedSC, err := app.LoadSidecar(tt.sc.Name)
require.NoError(err)
require.Equal(tt.expectedVM, string(loadedSC.VM))
})
}
}
func TestEVMRenameMigration_EmptyDir(t *testing.T) {
ux.NewUserLog(luxlog.NewNoOpLogger(), io.Discard)
require := require.New(t)
testDir := t.TempDir()
app := application.New()
app.Setup(testDir, luxlog.NewNoOpLogger(), config.New(), prompts.NewPrompter(), application.NewDownloader())
emptyChainName := "emptyChain"
chainDir := filepath.Join(app.GetChainsDir(), emptyChainName)
err := os.MkdirAll(chainDir, constants.DefaultPerms755)
require.NoError(err)
runner := migrationRunner{
showMsg: true,
running: false,
migrations: map[int]migrationFunc{
0: migrateEVMNames,
},
}
// run the migration
err = runner.run(app)
require.NoError(err)
}