mirror of
https://github.com/luxfi/upgrade.git
synced 2026-10-30 15:14:01 +00:00
- Config struct with network upgrade times for Mainnet, Testnet, Default - Validation methods for all upgrade phases (Apricot through Granite) - GetConfig(networkID) to get appropriate config for network - upgradetest/ subpackage with Fork enum and test helpers - Inline MainnetID/TestnetID constants to avoid circular deps Tests: PASS
49 lines
981 B
Go
49 lines
981 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package upgrade
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestValidDefaultUpgrades(t *testing.T) {
|
|
for _, upgradeTest := range []struct {
|
|
name string
|
|
upgrade Config
|
|
}{
|
|
{
|
|
name: "Default",
|
|
upgrade: Default,
|
|
},
|
|
{
|
|
name: "Testnet",
|
|
upgrade: Testnet,
|
|
},
|
|
{
|
|
name: "Mainnet",
|
|
upgrade: Mainnet,
|
|
},
|
|
} {
|
|
t.Run(upgradeTest.name, func(t *testing.T) {
|
|
require := require.New(t)
|
|
require.NoError(upgradeTest.upgrade.Validate())
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestInvalidUpgrade(t *testing.T) {
|
|
require := require.New(t)
|
|
firstUpgradeTime := time.Now()
|
|
invalidSecondUpgradeTime := firstUpgradeTime.Add(-1 * time.Second)
|
|
upgrade := Config{
|
|
ApricotPhase1Time: firstUpgradeTime,
|
|
ApricotPhase2Time: invalidSecondUpgradeTime,
|
|
}
|
|
err := upgrade.Validate()
|
|
require.ErrorIs(err, ErrInvalidUpgradeTimes)
|
|
}
|