Skip to content

Commit

Permalink
add major upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Nov 6, 2023
1 parent de21d42 commit e6b1e1c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestMinorVersionCompatibility(t *testing.T) {
require.NoError(t, testnet.Setup())
require.NoError(t, testnet.Start())

// TODO: with upgrade tests we should simulate a far broader range of transactions
sequences := txsim.NewBlobSequence(txsim.NewRange(200, 4000), txsim.NewRange(1, 3)).Clone(5)
sequences = append(sequences, txsim.NewSendSequence(4, 1000, 100).Clone(5)...)

Expand Down Expand Up @@ -116,7 +117,6 @@ func TestMinorVersionCompatibility(t *testing.T) {

// end the tx sim
cancel()

err = <-errCh
require.True(t, errors.Is(err, context.Canceled), err.Error())
}
Expand All @@ -137,6 +137,8 @@ func MajorUpgradeToV2(t *testing.T) {
r := rand.New(rand.NewSource(seed))
upgradeHeight := int64(10)
startingVersion := versions.Random(r).String()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

preloader, err := knuu.NewPreloader()
require.NoError(t, err)
Expand All @@ -155,6 +157,30 @@ func MajorUpgradeToV2(t *testing.T) {
t.Log("Starting node", "node", i, "version", v)
require.NoError(t, testnet.CreateGenesisNode(v, 10000000, upgradeHeight))
}

kr, err := testnet.CreateAccount("alice", 1e12)
require.NoError(t, err)

errCh := make(chan error)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
opts := txsim.DefaultOptions().WithSeed(seed).SuppressLogs()
sequences := txsim.NewBlobSequence(txsim.NewRange(200, 4000), txsim.NewRange(1, 3)).Clone(5)
sequences = append(sequences, txsim.NewSendSequence(4, 1000, 100).Clone(5)...)
go func() {
errCh <- txsim.Run(ctx, testnet.GRPCEndpoints()[0], kr, encCfg, opts, sequences...)
}()

// wait for all nodes to move pass the upgrade height
for i := 0; i < numNodes; i++ {
client, err := testnet.Node(i).Client()
require.NoError(t, err)
require.NoError(t, waitForHeight(ctx, client, upgradeHeight+2, 30*time.Second))
}

// end txsim
cancel()
err = <-errCh
require.True(t, errors.Is(err, context.Canceled), err.Error())
}

func getHeight(ctx context.Context, client *http.HTTP, period time.Duration) (int64, error) {
Expand Down

0 comments on commit e6b1e1c

Please sign in to comment.