Skip to content

Commit 85a10e3

Browse files
will-dzchrisli30
authored andcommitted
fix: clean up wallets created by ListWallets in test to prevent state leakage
1 parent be5eebd commit 85a10e3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

core/taskengine/wallet_count_limit_fix_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,17 @@ func TestWalletCountLimitDoesNotBlockExistingWalletAccess(t *testing.T) {
9191
// to access the existing wallet.
9292

9393
// Reset the database to have just 1 wallet initially
94-
// Remove the second wallet created in the setup
95-
db.Delete([]byte(WalletStorageKey(user.Address, addr2.Hex())))
94+
// Clean up any wallets that might have been created by previous subtests (e.g., ListWallets)
95+
// by deleting all wallets and recreating just wallet1
96+
dbItems, err := db.GetByPrefix(WalletByOwnerPrefix(user.Address))
97+
require.NoError(t, err)
98+
for _, item := range dbItems {
99+
db.Delete(item.Key)
100+
}
101+
102+
// Recreate wallet1 to ensure clean state
103+
err = StoreWallet(db, user.Address, wallet1)
104+
require.NoError(t, err)
96105

97106
// Now we have 1 wallet (limit=2), so we can create one more
98107
// First, call GetWallet to create a wallet with salt=999 (this should succeed)

0 commit comments

Comments
 (0)