Skip to content

Commit b9d34db

Browse files
committed
feat: added check to revert migration event for already created event on one chain
1 parent 226aea1 commit b9d34db

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

test/integration/utss/fund_migration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ func TestInitiateFundMigration(t *testing.T) {
201201
_, err := app.UtssKeeper.InitiateFundMigration(ctx, oldKeyId, testChain)
202202
require.NoError(t, err)
203203

204-
// Try again — should fail
204+
// Try again — should fail (same chain already has pending migration)
205205
_, err = app.UtssKeeper.InitiateFundMigration(ctx, oldKeyId, testChain)
206-
require.ErrorContains(t, err, "pending migration already exists")
206+
require.ErrorContains(t, err, "pending migration already exists for chain")
207207
})
208208
}
209209

x/utss/keeper/msg_initiate_fund_migration.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ func (k Keeper) InitiateFundMigration(ctx context.Context, oldKeyId, chain strin
5858
return 0, fmt.Errorf("chain %s still has pending outbounds; wait for them to drain before migration", chain)
5959
}
6060

61-
// 6. Check no existing PENDING migration for this (old_key_id, chain) combo
61+
// 6. Check no existing PENDING migration for this chain
6262
err = k.PendingMigrations.Walk(ctx, nil, func(migrationId uint64, _ uint64) (bool, error) {
6363
m, err := k.FundMigrations.Get(ctx, migrationId)
6464
if err != nil {
6565
return true, err
6666
}
67-
if m.OldKeyId == oldKeyId && m.Chain == chain {
68-
return true, fmt.Errorf("pending migration already exists for key %s on chain %s (migration_id: %d)",
69-
oldKeyId, chain, migrationId)
67+
if m.Chain == chain {
68+
return true, fmt.Errorf("pending migration already exists for chain %s (migration_id: %d, old_key: %s)",
69+
chain, migrationId, m.OldKeyId)
7070
}
7171
return false, nil
7272
})

0 commit comments

Comments
 (0)