mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
Add package-level constants for repeated string literals across the codebase: - LuxEVMName in deploy.go for VM naming - MainnetSubnetBlockchainID in start_with_state.go - PChainID in chain/config.go - pqSuffix, schemeLSAG, schemeLattice, schemeLatticeFull, schemeLatticePQ in keycmd - rentalPlan* and validatorMgmtHybrid in l1cmd/migrate.go - vmType* constants in l3cmd/create.go - networkTypeCustom, networkTypeLocal in networkcmd - vmNameEVM, orgLuxfi in vmcmd - WalletConnectName in key package - platformDarwin in backend_test.go - strTrue in e2e tests This addresses all goconst linter warnings requiring string literals with 3+ occurrences to be defined as constants.
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package vm
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/luxfi/cli/internal/mocks"
|
|
"github.com/luxfi/cli/pkg/application"
|
|
"github.com/luxfi/cli/pkg/statemachine"
|
|
"github.com/luxfi/crypto"
|
|
"github.com/luxfi/geth/common"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
var (
|
|
testAirdropAddress = common.HexToAddress("0x098B69E43b1720Bd12378225519d74e5F3aD0eA5")
|
|
testAirdropCryptoAddress = crypto.HexToAddress("0x098B69E43b1720Bd12378225519d74e5F3aD0eA5")
|
|
)
|
|
|
|
func TestGetAllocationCustomUnits(t *testing.T) {
|
|
require := setupTest(t)
|
|
app := application.New()
|
|
mockPrompt := &mocks.SDKPrompter{}
|
|
app.Prompt = mockPrompt
|
|
|
|
airdropInputAmount := new(big.Int)
|
|
airdropInputAmount.SetString("1000000", 10)
|
|
|
|
// Expected amount is input * oneLux (10^18)
|
|
expectedAmount := new(big.Int)
|
|
expectedAmount.SetString("1000000000000000000000000", 10) // 1000000 * 10^18
|
|
|
|
mockPrompt.On("CaptureAddress", mock.Anything).Return(testAirdropCryptoAddress, nil)
|
|
mockPrompt.On("CapturePositiveBigInt", mock.Anything).Return(airdropInputAmount, nil)
|
|
mockPrompt.On("CaptureNoYes", mock.Anything).Return(false, nil)
|
|
|
|
alloc, direction, err := getEVMAllocation(app)
|
|
require.NoError(err)
|
|
require.Equal(direction, statemachine.Forward)
|
|
|
|
require.Equal(alloc[testAirdropAddress].Balance, expectedAmount)
|
|
}
|