Skip to content

Commit

Permalink
Use single 'storage' across migration and test
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Nov 7, 2023
1 parent 85057f4 commit 5bdcb9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
14 changes: 6 additions & 8 deletions migrations/account_type/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ type AccountTypeMigration struct {
interpreter *interpreter.Interpreter
}

func NewAccountTypeMigration(runtime runtime.Runtime, context runtime.Context) (*AccountTypeMigration, error) {
storage, inter, err := runtime.Storage(context)
if err != nil {
return nil, err
}

func NewAccountTypeMigration(
interpreter *interpreter.Interpreter,
storage *runtime.Storage,
) *AccountTypeMigration {
return &AccountTypeMigration{
storage: storage,
interpreter: inter,
}, nil
interpreter: interpreter,
}
}

func (m *AccountTypeMigration) Migrate(
Expand Down
26 changes: 2 additions & 24 deletions migrations/account_type/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,7 @@ func TestMigration(t *testing.T) {

// Migrate

rt := runtime_utils.NewTestInterpreterRuntime()
runtimeInterface := &runtime_utils.TestRuntimeInterface{
Storage: ledger,
}

migration, err := NewAccountTypeMigration(
rt,
runtime.Context{
Interface: runtimeInterface,
},
)
require.NoError(t, err)
migration := NewAccountTypeMigration(inter, storage)

reporter := newTestReporter()

Expand Down Expand Up @@ -525,18 +514,7 @@ func TestNestedTypeValueMigration(t *testing.T) {

// Migrate

rt := runtime_utils.NewTestInterpreterRuntime()
runtimeInterface := &runtime_utils.TestRuntimeInterface{
Storage: ledger,
}

migration, err := NewAccountTypeMigration(
rt,
runtime.Context{
Interface: runtimeInterface,
},
)
require.NoError(t, err)
migration := NewAccountTypeMigration(inter, storage)

migration.Migrate(
&migrations.AddressSliceIterator{
Expand Down

0 comments on commit 5bdcb9b

Please sign in to comment.