Skip to content

Commit

Permalink
partially disable the failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur committed Feb 2, 2024
1 parent 10f827f commit 566b5bc
Showing 1 changed file with 73 additions and 72 deletions.
145 changes: 73 additions & 72 deletions plugin/evm/vm_upgrade_bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/ava-labs/avalanchego/snow"
commonEng "github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/vms/components/chain"
"github.com/ava-labs/subnet-evm/core"
"github.com/ava-labs/subnet-evm/core/types"
Expand Down Expand Up @@ -229,80 +230,80 @@ func TestVMUpgradeBytesPrecompile(t *testing.T) {
// }
// }

// This won't work with mainnet is disabled.
// func TestMandatoryUpgradesEnforced(t *testing.T) {
// // make genesis w/ fork at block 5
// // but this should not be used because we are enforcing
// // network upgrades within the code
// var genesis core.Genesis
// if err := json.Unmarshal([]byte(genesisJSONPreSubnetEVM), &genesis); err != nil {
// t.Fatalf("could not unmarshal genesis bytes: %s", err)
// }
// genesisSubnetEVMTimestamp := utils.NewUint64(5)
// genesis.Config.SubnetEVMTimestamp = genesisSubnetEVMTimestamp
// genesisBytes, err := json.Marshal(&genesis)
// if err != nil {
// t.Fatalf("could not unmarshal genesis bytes: %s", err)
// }
func TestMandatoryUpgradesEnforced(t *testing.T) {
// make genesis w/ fork at block 5
// but this should not be used because we are enforcing
// network upgrades within the code
var genesis core.Genesis
if err := json.Unmarshal([]byte(genesisJSONPreSubnetEVM), &genesis); err != nil {
t.Fatalf("could not unmarshal genesis bytes: %s", err)
}
genesisSubnetEVMTimestamp := utils.NewUint64(5)
genesis.Config.SubnetEVMTimestamp = genesisSubnetEVMTimestamp
genesisBytes, err := json.Marshal(&genesis)
if err != nil {
t.Fatalf("could not unmarshal genesis bytes: %s", err)
}

// // initialize the VM with these upgrade bytes
// tests := []struct {
// networkID uint32
// expected bool
// }{
// {
// networkID: constants.MainnetID,
// expected: true,
// },
// {
// networkID: constants.FujiID,
// expected: true,
// },
// {
// networkID: constants.LocalID,
// expected: false,
// },
// {
// networkID: constants.UnitTestID,
// expected: false,
// },
// }
// initialize the VM with these upgrade bytes
tests := []struct {
networkID uint32
expected bool
}{
// This won't work because mainnet is not suppored in fuji release.
// {
// networkID: constants.MainnetID,
// expected: true,
// },
{
networkID: constants.FujiID,
expected: true,
},
{
networkID: constants.LocalID,
expected: false,
},
{
networkID: constants.UnitTestID,
expected: false,
},
}

// for _, test := range tests {
// t.Run(fmt.Sprintf("networkID %d", test.networkID), func(t *testing.T) {
// vm := &VM{}
// ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, string(genesisBytes))
// ctx.NetworkID = test.networkID
// appSender := &commonEng.SenderTest{T: t}
// appSender.CantSendAppGossip = true
// appSender.SendAppGossipF = func(context.Context, []byte) error { return nil }
// err := vm.Initialize(
// context.Background(),
// ctx,
// dbManager,
// genesisBytes,
// nil,
// nil,
// issuer,
// []*commonEng.Fx{},
// appSender,
// )
// require.NoError(t, err, "error initializing GenesisVM")

// require.NoError(t, vm.SetState(context.Background(), snow.Bootstrapping))
// require.NoError(t, vm.SetState(context.Background(), snow.NormalOp))

// defer func() {
// if err := vm.Shutdown(context.Background()); err != nil {
// t.Fatal(err)
// }
// }()

// // verify upgrade is rescheduled
// require.Equal(t, test.expected, vm.chainConfig.IsSubnetEVM(0))
// })
// }
// }
for _, test := range tests {
t.Run(fmt.Sprintf("networkID %d", test.networkID), func(t *testing.T) {
vm := &VM{}
ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, string(genesisBytes))
ctx.NetworkID = test.networkID
appSender := &commonEng.SenderTest{T: t}
appSender.CantSendAppGossip = true
appSender.SendAppGossipF = func(context.Context, []byte) error { return nil }
err := vm.Initialize(
context.Background(),
ctx,
dbManager,
genesisBytes,
nil,
nil,
issuer,
[]*commonEng.Fx{},
appSender,
)
require.NoError(t, err, "error initializing GenesisVM")

require.NoError(t, vm.SetState(context.Background(), snow.Bootstrapping))
require.NoError(t, vm.SetState(context.Background(), snow.NormalOp))

defer func() {
if err := vm.Shutdown(context.Background()); err != nil {
t.Fatal(err)
}
}()

// verify upgrade is rescheduled
require.Equal(t, test.expected, vm.chainConfig.IsSubnetEVM(0))
})
}
}

func mustMarshal(t *testing.T, v interface{}) string {
b, err := json.Marshal(v)
Expand Down

0 comments on commit 566b5bc

Please sign in to comment.