Skip to content

Commit

Permalink
Merge pull request #5470 from onflow/bastian/optimize-deployment-migr…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
turbolent authored Mar 4, 2024
2 parents f19e509 + 579abb8 commit 2e9bbef
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions cmd/util/ledger/migrations/deploy_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,32 @@ func TestDeploy(t *testing.T) {
zerolog.New(zerolog.NewTestWriter(t)),
)

payloads, err := newBootstrapPayloads(chainID)
bootstrapPayloads, err := newBootstrapPayloads(chainID)
require.NoError(t, err)

newPayloads, err := migration(payloads)
filteredPayloads := make([]*ledger.Payload, 0, len(bootstrapPayloads))

// TODO: move to NewTransactionBasedMigration

// Filter the bootstrapped payloads to only include the target account (service account)
// and the account where the fungible token is deployed

for _, payload := range bootstrapPayloads {
registerID, _, err := convert.PayloadToRegister(payload)
require.NoError(t, err)

if len(registerID.Owner) > 0 {
registerAddress := flow.Address([]byte(registerID.Owner))
switch registerAddress {
case targetAddress, fungibleTokenAddress:
filteredPayloads = append(filteredPayloads, payload)
}
} else {
filteredPayloads = append(filteredPayloads, payload)
}
}

newPayloads, err := migration(filteredPayloads)
require.NoError(t, err)

txBody := flow.NewTransactionBody().
Expand Down

0 comments on commit 2e9bbef

Please sign in to comment.