-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/osmosis-labs/osmosis/v21/x/incentives/keeper" | ||
lockuptypes "github.com/osmosis-labs/osmosis/v21/x/lockup/types" | ||
) | ||
|
||
// This test validates that the FilterLocksByMinDuration function | ||
// copies the correct locks when filtering. | ||
// It helps to ensure that we do not use a wrong pointer by referencing | ||
// a loop variable. | ||
func TestFilterLocksByMinDuration(t *testing.T) { | ||
const ( | ||
numLocks = 3 | ||
minDuration = 2 | ||
) | ||
|
||
locks := make([]lockuptypes.PeriodLock, numLocks) | ||
for i := 0; i < numLocks; i++ { | ||
locks[i] = lockuptypes.PeriodLock{ | ||
ID: uint64(i + 1), | ||
Duration: minDuration, | ||
} | ||
} | ||
|
||
filteredLocks := keeper.FilterLocksByMinDuration(locks, minDuration) | ||
|
||
require.Equal(t, len(locks), len(filteredLocks)) | ||
|
||
for i := 0; i < len(locks); i++ { | ||
require.Equal(t, locks[i].ID, filteredLocks[i].ID) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters