From 091ec822cca4312e9bf3a08088985985218638d2 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 27 Nov 2024 19:56:34 -0500 Subject: [PATCH] add test for removing non-existent tracker --- x/crosschain/keeper/outbound_tracker_test.go | 36 +++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/x/crosschain/keeper/outbound_tracker_test.go b/x/crosschain/keeper/outbound_tracker_test.go index 7eddcc2cfe..ad535739d1 100644 --- a/x/crosschain/keeper/outbound_tracker_test.go +++ b/x/crosschain/keeper/outbound_tracker_test.go @@ -42,19 +42,29 @@ func TestOutboundTrackerGet(t *testing.T) { } } func TestOutboundTrackerRemove(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) - items := createNOutboundTracker(k, ctx, 10) - for _, item := range items { - k.RemoveOutboundTrackerFromStore(ctx, - item.ChainId, - item.Nonce, - ) - _, found := k.GetOutboundTracker(ctx, - item.ChainId, - item.Nonce, - ) - require.False(t, found) - } + t.Run("Remove tracker if it exists", func(t *testing.T) { + keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) + items := createNOutboundTracker(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveOutboundTrackerFromStore(ctx, + item.ChainId, + item.Nonce, + ) + _, found := keeper.GetOutboundTracker(ctx, + item.ChainId, + item.Nonce, + ) + require.False(t, found) + } + }) + + t.Run("Do nothing if tracker doesn't exist", func(t *testing.T) { + keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) + require.NotPanics(t, func() { + keeper.RemoveOutboundTrackerFromStore(ctx, 1, 1) + }) + }) + } func TestOutboundTrackerGetAll(t *testing.T) {