Skip to content

Commit

Permalink
Remove local chain config from e2e test (#3293)
Browse files Browse the repository at this point in the history
Signed-off-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
  • Loading branch information
3 people authored Sep 2, 2024
1 parent e8c257f commit 9b03425
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/DataDog/zstd v1.5.2
github.com/NYTimes/gziphandler v1.1.1
github.com/antithesishq/antithesis-sdk-go v0.3.8
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732
github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8=
github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180/go.mod h1:/wNBVq7J7wlC2Kbov7kk6LV5xZvau7VF9zwTVOeyAjY=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 h1:wlhGJbmb7s3bU2QWtxKjscGjfHknQiq+cVhhUjONsB8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732/go.mod h1:RkQLaQ961Xe/sUb3ycn4Qi18vPPuEetTqDf2eDcquAs=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests.upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ fi
# local network, this flag must be updated to the last compatible
# version with the latest code.
#
# v1.11.0 activates Durango.
DEFAULT_VERSION="1.11.0"
# v1.11.3 fixes a regression in Coreth genesis for custom networks.
DEFAULT_VERSION="1.11.3"

VERSION="${1:-${DEFAULT_VERSION}}"
if [[ -z "${VERSION}" ]]; then
Expand Down
8 changes: 5 additions & 3 deletions tests/fixture/tmpnet/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ func NewTestGenesis(
)
}

chainID := big.NewInt(int64(networkID))
// Define C-Chain genesis
cChainGenesis := &core.Genesis{
Config: params.AvalancheLocalChainConfig,
Difficulty: big.NewInt(0), // Difficulty is a mandatory field
Timestamp: uint64(upgrade.InitiallyActiveTime.Unix()), // This time enables Avalanche upgrades by default
// TODO: remove this after Etna and set only the chainID
Config: params.GetChainConfig(upgrade.Default, chainID), // upgrade will be again set by VM according to the snow.Context
Difficulty: big.NewInt(0), // Difficulty is a mandatory field
Timestamp: uint64(upgrade.InitiallyActiveTime.Unix()), // This time enables Avalanche upgrades by default
GasLimit: defaultGasLimit,
Alloc: cChainBalances,
}
Expand Down
34 changes: 16 additions & 18 deletions tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
package upgrade

import (
"encoding/base64"
"encoding/json"
"flag"
"fmt"
"testing"

"github.com/ava-labs/coreth/core"
"github.com/onsi/ginkgo/v2"
"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/upgrade/upgradetest"
)

func TestUpgrade(t *testing.T) {
Expand Down Expand Up @@ -49,23 +50,20 @@ var _ = ginkgo.Describe("[Upgrade]", func() {
ginkgo.It("can upgrade versions", func() {
network := tmpnet.NewDefaultNetwork("avalanchego-upgrade")

{
// Get the default genesis so we can modify it
genesis, err := network.DefaultGenesis()
require.NoError(err)
network.Genesis = genesis
// Etna enables Cancun which modifies the outcome of the C-Chain genesis
// This is because of new header fields that modify the genesis block hash.
// This code can be removed once the Etna upgrade is activated.
cChainGenesis := new(core.Genesis)
cChainGenesisStr := network.Genesis.CChainGenesis
require.NoError(json.Unmarshal([]byte(cChainGenesisStr), cChainGenesis))
unscheduledActivationTime := uint64(upgrade.UnscheduledActivationTime.Unix())
cChainGenesis.Config.EtnaTime = &unscheduledActivationTime
cChainGenesisBytes, err := json.Marshal(cChainGenesis)
require.NoError(err)
network.Genesis.CChainGenesis = string(cChainGenesisBytes)
// Get the default genesis so we can modify it
genesis, err := network.DefaultGenesis()
require.NoError(err)
network.Genesis = genesis

// Configure network upgrade flag
latestUnscheduled := upgradetest.GetConfig(upgradetest.Latest - 1)
upgradeJSON, err := json.Marshal(latestUnscheduled)
require.NoError(err)
upgradeBase64 := base64.StdEncoding.EncodeToString(upgradeJSON)
if network.DefaultFlags == nil {
network.DefaultFlags = tmpnet.FlagsMap{}
}
network.DefaultFlags[config.UpgradeFileContentKey] = upgradeBase64

e2e.StartNetwork(tc, network, avalancheGoExecPath, "" /* pluginDir */, 0 /* shutdownDelay */, false /* reuseNetwork */)

Expand Down

0 comments on commit 9b03425

Please sign in to comment.