Skip to content

Commit

Permalink
go/oasis-test-runner: support for testing update handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Aug 5, 2021
1 parent 20cc579 commit 3b81a13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go/oasis-test-runner/scenario/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func RegisterScenarios() error {
// Genesis file test.
GenesisFile,
// Node upgrade tests.
NodeUpgrade,
NodeUpgradeDummy,
NodeUpgradeCancel,
// Debonding entries from genesis test.
Debond,
Expand Down
20 changes: 12 additions & 8 deletions go/oasis-test-runner/scenario/e2e/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
)

var (
// NodeUpgrade is the node upgrade scenario.
NodeUpgrade scenario.Scenario = newNodeUpgradeImpl()
// NodeUpgradeDummy is the node upgrade dummy scenario.
NodeUpgradeDummy scenario.Scenario = newNodeUpgradeImpl(migrations.DummyUpgradeHandler)

malformedDescriptor = []byte(`{
"v": 1,
Expand All @@ -56,6 +56,8 @@ type nodeUpgradeImpl struct {

ctx context.Context
currentEpoch beacon.EpochTime

handlerName string
}

func (sc *nodeUpgradeImpl) writeDescriptor(name string, content []byte) (string, error) {
Expand Down Expand Up @@ -107,18 +109,20 @@ func (sc *nodeUpgradeImpl) restart(wait bool) error {
}
}

func newNodeUpgradeImpl() scenario.Scenario {
func newNodeUpgradeImpl(handlerName string) scenario.Scenario {
sc := &nodeUpgradeImpl{
E2E: *NewE2E("node-upgrade"),
ctx: context.Background(),
E2E: *NewE2E("node-upgrade-" + handlerName),
ctx: context.Background(),
handlerName: handlerName,
}
return sc
}

func (sc *nodeUpgradeImpl) Clone() scenario.Scenario {
return &nodeUpgradeImpl{
E2E: sc.E2E.Clone(),
ctx: context.Background(),
E2E: sc.E2E.Clone(),
ctx: context.Background(),
handlerName: sc.handlerName,
}
}

Expand Down Expand Up @@ -276,7 +280,7 @@ func (sc *nodeUpgradeImpl) Run(childEnv *env.Env) error { // nolint: gocyclo
store.Close()

validDescriptor := baseDescriptor
validDescriptor.Handler = migrations.DummyUpgradeHandler
validDescriptor.Handler = sc.handlerName
validDescriptor.Epoch = sc.currentEpoch + 1
desc, err = json.Marshal(validDescriptor)
if err != nil {
Expand Down

0 comments on commit 3b81a13

Please sign in to comment.