Files
cli/pkg/vm/createEvm_test.go
zeekay c3b59414d7 strip Eth*/Keccak* aliases workspace-wide (no aliases)
Forward-only completion of the strip-aliases work in lockstep with:
  crypto v1.19.16, utxo v0.3.3, node v1.27.13, sdk v1.16.63,
  netrunner v1.18.6, coreth v1.22.5.

Canonical surface across the workspace is EVMAddress / EVMKeychain /
GetByEVM / EVMAddresses — no KeccakAddress, no EthAddress, no
EthKeychain. \"EVM-runtime account address\" IS the data model;
Keccak256(secp256k1 pubkey) is HOW.

Touched:
  cmd/keycmd/derive.go        ValidatorKeyInfo drops KeccakAddress
                              + EthAddress JSON aliases; only
                              evm_address remains
  internal/testutils/addresses.go
                              drop GenerateKeccakAddrs +
                              GenerateEthAddrs aliases; only
                              GenerateEVMAddrs remains
  cmd/rpccmd/transfer.go       kcAdapter.EthAddresses() → .EVMAddresses();
                              WalletConfig.EthKeychain → .EVMKeychain
  pkg/chain/local.go           emptyEthKeychain → emptyEVMKeychain;
                              ethKc → evmKc (4 sites); EthKeychain
                              field → EVMKeychain
  pkg/chain/public.go          ethKc → evmKc, EthKeychain → EVMKeychain
  pkg/vm/createEvm_test.go     GenerateEthAddrs → GenerateEVMAddrs
  tests/e2e/utils/helpers.go   EthKeychain: nil → EVMKeychain: nil (3x)
  cmd/networkcmd/status.go     status.String() → %+v (ZAP-native rpcpb
                              has no String() method)
  pkg/chain/local.go           deployBlockchainsInfo.String() → %+v;
                              resp.GetClusterInfo() → resp.ClusterInfo
                              (ZAP-native field access)

Deps:
  sdk     v1.16.61 → v1.16.63
  netrunner v1.18.5-pre → v1.18.6
  coreth  v1.21.48 → v1.22.5
  utxo    v0.3.1   → v0.3.3
  crypto  v1.19.13 → v1.19.16
  node    v1.26.25-pre → v1.27.2 (indirect)
2026-05-24 07:29:53 -07:00

144 lines
3.1 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package vm
import (
"errors"
"math/big"
"testing"
"github.com/luxfi/cli/internal/testutils"
"github.com/luxfi/crypto"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
"github.com/stretchr/testify/require"
)
func Test_ensureAdminsFunded(t *testing.T) {
cryptoAddrs, err := testutils.GenerateEVMAddrs(5)
require.NoError(t, err)
// Convert crypto.Address to common.Address for GenesisAlloc
addrs := make([]common.Address, len(cryptoAddrs))
for i, addr := range cryptoAddrs {
addrs[i] = common.Address(addr)
}
type test struct {
name string
alloc types.GenesisAlloc
admins []crypto.Address
shouldFail bool
}
tests := []test{
{
name: "One address funded",
alloc: types.GenesisAlloc{
addrs[0]: {},
addrs[1]: {
Balance: big.NewInt(42),
},
addrs[2]: {},
},
admins: []crypto.Address{cryptoAddrs[1]},
shouldFail: false,
},
{
name: "Two addresses funded",
alloc: types.GenesisAlloc{
addrs[2]: {},
addrs[3]: {
Balance: big.NewInt(42),
},
addrs[4]: {
Balance: big.NewInt(42),
},
},
admins: []crypto.Address{cryptoAddrs[3], cryptoAddrs[4]},
shouldFail: false,
},
{
name: "Two addresses in Genesis but no funds",
alloc: types.GenesisAlloc{
addrs[0]: {
Balance: big.NewInt(0),
},
addrs[1]: {},
addrs[2]: {},
},
admins: []crypto.Address{cryptoAddrs[0], cryptoAddrs[2]},
shouldFail: true,
},
{
name: "No address funded",
alloc: types.GenesisAlloc{
addrs[0]: {},
addrs[1]: {},
addrs[2]: {},
},
admins: []crypto.Address{cryptoAddrs[3], cryptoAddrs[4]},
shouldFail: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
err := ensureAdminsHaveBalance(tt.admins, tt.alloc)
if tt.shouldFail {
require.Error(err)
} else {
require.NoError(err)
}
})
}
}
func Test_removePrecompile(t *testing.T) {
allowList := "allow list"
minter := "minter"
type test struct {
name string
precompileList []string
toRemove string
expectedResult []string
expectedErr error
}
tests := []test{
{
name: "Success",
precompileList: []string{allowList, minter},
toRemove: allowList,
expectedResult: []string{minter},
expectedErr: nil,
},
{
name: "Success reverse",
precompileList: []string{allowList, minter},
toRemove: minter,
expectedResult: []string{allowList},
expectedErr: nil,
},
{
name: "Failure",
precompileList: []string{minter},
toRemove: allowList,
expectedResult: []string{minter},
expectedErr: errors.New("string not in array"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
// Check how many selected
shortenedList, err := removePrecompile(tt.precompileList, tt.toRemove)
require.Equal(tt.expectedResult, shortenedList)
require.Equal(tt.expectedErr, err)
})
}
}