Commit e16c8ee6 authored by Roman's avatar Roman
Browse files

godoc

parent 4588ff0d
Showing with 9 additions and 4 deletions
+9 -4
......@@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestCalcExitPoolCoinsFromShares() {
}
// Test case shared by all pools to be tested.
allTestCases := mergeTestCases(validPools, sharedTestCases)
allTestCases := createTestCasesForGivenPools(validPools, sharedTestCases)
// Add individual test cases
allTestCases = append(allTestCases, &shareInTestCase{
......@@ -138,7 +138,7 @@ func (suite *KeeperTestSuite) TestCalcJoinPoolNoSwapShares() {
},
}
allTestCases := mergeTestCases(validPools, sharedTestCases)
allTestCases := createTestCasesForGivenPools(validPools, sharedTestCases)
// Indiividual test cases where pool model does not matter.
nonExistentPoolId := validPools[len(validPools)-1].poolId + 1
......@@ -381,7 +381,7 @@ func (suite *KeeperTestSuite) TestCalcJoinPoolShares() {
},
}
allTestCases := mergeTestCases(validPools, sharedTestCases)
allTestCases := createTestCasesForGivenPools(validPools, sharedTestCases)
// add inidividual test cases
nonExistentPoolId := validPools[len(validPools)-1].poolId + 1
......
......@@ -120,6 +120,8 @@ func (suite *KeeperTestSuite) fundAllAccountsWith(balances sdk.Coins) {
}
}
// initializeValidTestPools returns a list of all supported pool models.
// Each pool model has a pool with id created and a name assigned.
func (suite *KeeperTestSuite) initializeValidTestPools() []poolsCase {
return []poolsCase{
{
......@@ -133,7 +135,10 @@ func (suite *KeeperTestSuite) initializeValidTestPools() []poolsCase {
}
}
func mergeTestCases[T testCaseI](validPools []poolsCase, sharedTestCases []T) []T {
// createTestCasesForGivenPools creates a test case in sharedTestCases for each pool in validPools
// and returns the final merged list of all test cases.
// This helps to reduce code duplciation when testing the same logic for multiple pool models.
func createTestCasesForGivenPools[T testCaseI](validPools []poolsCase, sharedTestCases []T) []T {
allTestCases := make([]T, 0)
for _, pool := range validPools {
curPool := pool
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment