Skip to content

Commit 566b5bc

Browse files
committed
partially disable the failing test
1 parent 10f827f commit 566b5bc

File tree

1 file changed

+73
-72
lines changed

1 file changed

+73
-72
lines changed

plugin/evm/vm_upgrade_bytes_test.go

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/ava-labs/avalanchego/snow"
1616
commonEng "github.com/ava-labs/avalanchego/snow/engine/common"
17+
"github.com/ava-labs/avalanchego/utils/constants"
1718
"github.com/ava-labs/avalanchego/vms/components/chain"
1819
"github.com/ava-labs/subnet-evm/core"
1920
"github.com/ava-labs/subnet-evm/core/types"
@@ -229,80 +230,80 @@ func TestVMUpgradeBytesPrecompile(t *testing.T) {
229230
// }
230231
// }
231232

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

248-
// // initialize the VM with these upgrade bytes
249-
// tests := []struct {
250-
// networkID uint32
251-
// expected bool
252-
// }{
253-
// {
254-
// networkID: constants.MainnetID,
255-
// expected: true,
256-
// },
257-
// {
258-
// networkID: constants.FujiID,
259-
// expected: true,
260-
// },
261-
// {
262-
// networkID: constants.LocalID,
263-
// expected: false,
264-
// },
265-
// {
266-
// networkID: constants.UnitTestID,
267-
// expected: false,
268-
// },
269-
// }
248+
// initialize the VM with these upgrade bytes
249+
tests := []struct {
250+
networkID uint32
251+
expected bool
252+
}{
253+
// This won't work because mainnet is not suppored in fuji release.
254+
// {
255+
// networkID: constants.MainnetID,
256+
// expected: true,
257+
// },
258+
{
259+
networkID: constants.FujiID,
260+
expected: true,
261+
},
262+
{
263+
networkID: constants.LocalID,
264+
expected: false,
265+
},
266+
{
267+
networkID: constants.UnitTestID,
268+
expected: false,
269+
},
270+
}
270271

271-
// for _, test := range tests {
272-
// t.Run(fmt.Sprintf("networkID %d", test.networkID), func(t *testing.T) {
273-
// vm := &VM{}
274-
// ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, string(genesisBytes))
275-
// ctx.NetworkID = test.networkID
276-
// appSender := &commonEng.SenderTest{T: t}
277-
// appSender.CantSendAppGossip = true
278-
// appSender.SendAppGossipF = func(context.Context, []byte) error { return nil }
279-
// err := vm.Initialize(
280-
// context.Background(),
281-
// ctx,
282-
// dbManager,
283-
// genesisBytes,
284-
// nil,
285-
// nil,
286-
// issuer,
287-
// []*commonEng.Fx{},
288-
// appSender,
289-
// )
290-
// require.NoError(t, err, "error initializing GenesisVM")
291-
292-
// require.NoError(t, vm.SetState(context.Background(), snow.Bootstrapping))
293-
// require.NoError(t, vm.SetState(context.Background(), snow.NormalOp))
294-
295-
// defer func() {
296-
// if err := vm.Shutdown(context.Background()); err != nil {
297-
// t.Fatal(err)
298-
// }
299-
// }()
300-
301-
// // verify upgrade is rescheduled
302-
// require.Equal(t, test.expected, vm.chainConfig.IsSubnetEVM(0))
303-
// })
304-
// }
305-
// }
272+
for _, test := range tests {
273+
t.Run(fmt.Sprintf("networkID %d", test.networkID), func(t *testing.T) {
274+
vm := &VM{}
275+
ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, string(genesisBytes))
276+
ctx.NetworkID = test.networkID
277+
appSender := &commonEng.SenderTest{T: t}
278+
appSender.CantSendAppGossip = true
279+
appSender.SendAppGossipF = func(context.Context, []byte) error { return nil }
280+
err := vm.Initialize(
281+
context.Background(),
282+
ctx,
283+
dbManager,
284+
genesisBytes,
285+
nil,
286+
nil,
287+
issuer,
288+
[]*commonEng.Fx{},
289+
appSender,
290+
)
291+
require.NoError(t, err, "error initializing GenesisVM")
292+
293+
require.NoError(t, vm.SetState(context.Background(), snow.Bootstrapping))
294+
require.NoError(t, vm.SetState(context.Background(), snow.NormalOp))
295+
296+
defer func() {
297+
if err := vm.Shutdown(context.Background()); err != nil {
298+
t.Fatal(err)
299+
}
300+
}()
301+
302+
// verify upgrade is rescheduled
303+
require.Equal(t, test.expected, vm.chainConfig.IsSubnetEVM(0))
304+
})
305+
}
306+
}
306307

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

0 commit comments

Comments
 (0)