Files
evm/params/extras/config_test.go
zeekay c7c4b96b0f rename: Etna → Quasar Edition
Wire-level renames in EVM:
  - extras.NetworkUpgrades.EtnaTimestamp → QuasarTimestamp
    json tag etnaTimestamp → quasarTimestamp
  - extras.NetworkUpgrades.IsEtna()      → IsQuasar()
  - extras.LuxRules.IsEtna               → IsQuasar
  - params.RulesExtra.IsEtna             → IsQuasar
  - extras.TestEtnaChainConfig           → TestQuasarChainConfig
  - params.TestEtnaChainConfig           → TestQuasarChainConfig
  - upgradetest.Etna fork enum           → Quasar (luxfi/upgrade dep)

Test JSON fixtures (mainnet_upgrade_v46, testnet_upgrade_v47, embedded
genesis_skippostmerge_test, precompile_upgrade_rollout_test) flipped from
"etnaTimestamp" → "quasarTimestamp".

Also patched .disabled test files for grep cleanliness so future grep -rn
'Etna' returns 0 outside historical RELEASES.md.

Bumps luxfi/upgrade@main + luxfi/constants@main with their renamed symbols.
No backcompat aliases — forwards-only.
2026-06-02 23:01:55 -07:00

180 lines
5.1 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package extras
import (
"math/big"
"testing"
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/precompile/contracts/txallowlist"
"github.com/luxfi/evm/utils/utilstest"
"github.com/luxfi/geth/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func pointer[T any](v T) *T { return &v }
func TestChainConfigDescription(t *testing.T) {
// Test re-enabled for mainnet deployment
t.Parallel()
tests := map[string]struct {
config *ChainConfig
wantRegex string
}{
"nil": {},
"empty": {
config: &ChainConfig{},
wantRegex: `Lux Upgrades \(timestamp based\)\:
- EVM Timestamp: ( )+@nil( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
( - .+Timestamp: .+\n)+
Upgrade Config: {}
Fee Config: {}
Allow Fee Recipients: false
$`,
},
"set": {
config: &ChainConfig{
NetworkUpgrades: NetworkUpgrades{
EVMTimestamp: pointer(uint64(1)),
DurangoTimestamp: pointer(uint64(2)),
QuasarTimestamp: pointer(uint64(3)),
FortunaTimestamp: pointer(uint64(4)),
},
FeeConfig: commontype.FeeConfig{
GasLimit: big.NewInt(5),
TargetBlockRate: 6,
MinBaseFee: big.NewInt(7),
TargetGas: big.NewInt(8),
BaseFeeChangeDenominator: big.NewInt(9),
MinBlockGasCost: big.NewInt(10),
MaxBlockGasCost: big.NewInt(11),
BlockGasCostStep: big.NewInt(12),
},
AllowFeeRecipients: true,
UpgradeConfig: UpgradeConfig{
NetworkUpgradeOverrides: &NetworkUpgrades{
EVMTimestamp: pointer(uint64(13)),
},
StateUpgrades: []StateUpgrade{
{
BlockTimestamp: pointer(uint64(14)),
StateUpgradeAccounts: map[common.Address]StateUpgradeAccount{
{15}: {
Code: []byte{16},
},
},
},
},
},
},
wantRegex: `Lux Upgrades \(timestamp based\)\:
- EVM Timestamp: ( )+@1( )+\(https:\/\/github\.com\/luxfi\/node\/releases\/tag\/v1\.10\.0\)
( - .+Timestamp: .+\n)+
Upgrade Config: {"networkUpgradeOverrides":{"evmTimestamp":13},"stateUpgrades":\[{"blockTimestamp":14,"accounts":{"0x0f00000000000000000000000000000000000000":{"code":"0x10"}}}\]}
Fee Config: {"gasLimit":5,"targetBlockRate":6,"minBaseFee":7,"targetGas":8,"baseFeeChangeDenominator":9,"minBlockGasCost":10,"maxBlockGasCost":11,"blockGasCostStep":12}
Allow Fee Recipients: true
$`,
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
got := test.config.Description()
assert.Regexp(t, test.wantRegex, got, "config description mismatch")
})
}
}
func TestChainConfigVerify(t *testing.T) {
// Test re-enabled for mainnet deployment
t.Parallel()
validFeeConfig := commontype.FeeConfig{
GasLimit: big.NewInt(1),
TargetBlockRate: 1,
MinBaseFee: big.NewInt(1),
TargetGas: big.NewInt(1),
BaseFeeChangeDenominator: big.NewInt(1),
MinBlockGasCost: big.NewInt(1),
MaxBlockGasCost: big.NewInt(1),
BlockGasCostStep: big.NewInt(1),
}
tests := map[string]struct {
config ChainConfig
errRegex string
}{
"invalid_feeconfig": {
config: ChainConfig{
FeeConfig: commontype.FeeConfig{
GasLimit: nil,
},
},
errRegex: "^invalid fee config: ",
},
"invalid_precompile_upgrades": {
// Also see precompile_config_test.go TestVerifyWithChainConfig* tests
config: ChainConfig{
FeeConfig: validFeeConfig,
UpgradeConfig: UpgradeConfig{
PrecompileUpgrades: []PrecompileUpgrade{
// same precompile cannot be configured twice for the same timestamp
{Config: txallowlist.NewDisableConfig(pointer(uint64(1)))},
{Config: txallowlist.NewDisableConfig(pointer(uint64(1)))},
},
},
},
errRegex: "^invalid precompile upgrades: ",
},
"invalid_state_upgrades": {
config: ChainConfig{
FeeConfig: validFeeConfig,
UpgradeConfig: UpgradeConfig{
StateUpgrades: []StateUpgrade{
{BlockTimestamp: nil},
},
},
},
errRegex: "^invalid state upgrades: ",
},
"invalid_network_upgrades": {
config: ChainConfig{
FeeConfig: validFeeConfig,
NetworkUpgrades: NetworkUpgrades{
EVMTimestamp: nil,
},
LuxContext: LuxContext{ConsensusCtx: utilstest.NewTestConsensusContext(t)},
},
errRegex: "^invalid network upgrades: ",
},
"valid": {
config: ChainConfig{
FeeConfig: validFeeConfig,
NetworkUpgrades: NetworkUpgrades{
EVMTimestamp: pointer(uint64(0)), // Must be 0 (genesis activation)
DurangoTimestamp: pointer(uint64(0)), // Must be 0 for default
QuasarTimestamp: nil, // Optional
FortunaTimestamp: nil, // Optional
},
LuxContext: LuxContext{ConsensusCtx: utilstest.NewTestConsensusContext(t)},
},
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
err := test.config.Verify()
if test.errRegex == "" {
assert.NoError(t, err)
} else {
require.Error(t, err)
assert.Regexp(t, test.errRegex, err.Error())
}
})
}
}