Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint all tests #5127

Closed
wants to merge 158 commits into from
Closed
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
70cfbdc
TestJoinSwapExactAmountInConsistency
DongLieu Apr 27, 2023
37074cc
add cases corners
DongLieu May 4, 2023
f5dc71d
run golangci-lint and resolve ineffectual assignment to err
faddat May 3, 2023
9fa7369
go work sync
faddat May 7, 2023
c688011
waypoint in "check all errors in tests"
faddat May 7, 2023
ac5bcd2
50 error checks remaining
faddat May 7, 2023
3105a8a
42 errors remaining to check in tests
faddat May 7, 2023
cbed0c4
all tests pass and as many errors as possible have been checked
faddat May 7, 2023
31327a6
revert enabling golangci-lint to check tests, as it would always fail…
faddat May 7, 2023
2acfd0e
update changelog
faddat May 7, 2023
1e9eb0c
use thelper in golangci-lint without linting every test
faddat May 3, 2023
d624769
Update tests/e2e/containers/containers.go
faddat May 7, 2023
e9c621f
Merge remote-tracking branch 'origin/main' into faddat/check-all-errors
faddat May 7, 2023
d616f90
thelper for incentives bench test
faddat May 7, 2023
0a59632
unused code in tests
faddat May 7, 2023
8ae270d
Update x/concentrated-liquidity/position_test.go
faddat May 7, 2023
ddc5487
Merge branch 'main' into faddat/check-all-errors
faddat May 7, 2023
560388c
fix forced type assertions
faddat May 7, 2023
b70f80a
revert change to linter config
faddat May 7, 2023
b2d1fab
Update tests/e2e/e2e_test.go
faddat May 8, 2023
85c7ecb
Update x/concentrated-liquidity/pool_test.go
faddat May 8, 2023
8e573d7
skip pool = poolI
faddat May 8, 2023
eb9cc68
update swap_test.go to test that cl type assertions fail
faddat May 8, 2023
56c6152
trial
faddat May 8, 2023
daa610e
we needed pool because it's used to CalcInGivenOut
faddat May 8, 2023
93f5581
Merge branch 'main' into faddat/check-all-errors
faddat May 8, 2023
e243555
Merge remote-tracking branch 'origin/main' into faddat/check-all-errors
faddat May 8, 2023
16c6c97
re-add skip state sync
faddat May 8, 2023
39f6fc4
Merge branch 'faddat/unused-in-tests' into accumulate
faddat May 8, 2023
6bc25aa
Merge branch 'faddat/forcetypeassert' into accumulate
faddat May 8, 2023
268d276
everything but oddities
faddat May 8, 2023
a558e7b
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 9, 2023
ce1675f
Update CHANGELOG.md
faddat May 9, 2023
66c0616
Merge branch 'main' into faddat/check-all-errors
faddat May 9, 2023
e7d37d0
more test cases for TestValidatePoolLiquidity()
DongLieu May 9, 2023
d05c314
return error in SetIncentiveRecord
faddat May 9, 2023
1d07817
revert change to .golanci.yml
faddat May 9, 2023
9d2ee5a
Update x/concentrated-liquidity/pool_test.go
faddat May 9, 2023
bc461ab
Update x/concentrated-liquidity/pool_test.go
faddat May 9, 2023
cb22e58
Update x/gamm/keeper/swap_test.go
faddat May 9, 2023
b9f45b1
Merge branch 'faddat/check-all-errors' into lint-all-tests
faddat May 9, 2023
7ee03f6
Merge remote-tracking branch 'origin/faddat/forcetypeassert' into lin…
faddat May 9, 2023
8ed22fc
golangci-lint run ./... --fix
faddat May 9, 2023
2d93ccf
style: lint stableswap the same as the rest of osmosis (#5105)
faddat May 9, 2023
20d9c04
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 10, 2023
500ea1f
Add test cases for TestSwapOutAmtGivenIn()
DongLieu May 10, 2023
624cadb
add return err for prepareCustomBalancerPool()
DongLieu May 10, 2023
f4d0555
add testcase with non zero exit fee
DongLieu May 10, 2023
56e64ff
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 10, 2023
b6b2da4
res.liquidity
faddat May 10, 2023
981eb4f
mask generated code from the linter, and fix makezero lint
faddat May 10, 2023
665726f
almost :) - commit contains numerous small lint fixes for tests
faddat May 10, 2023
5a5b16a
fix spelling mistake :)
faddat May 10, 2023
179f100
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 10, 2023
beb40e5
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 10, 2023
b51a248
rename
DongLieu May 11, 2023
365e8d2
add calculations lead to number
DongLieu May 11, 2023
26260cd
remove testcase poolExitFee > 0
DongLieu May 11, 2023
3f0c439
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 11, 2023
8f99b2d
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 12, 2023
faf7fce
suite => s
faddat May 12, 2023
bc8434c
suite -> s
faddat May 12, 2023
1bf171e
don't needlessly use fmt.Sprintf
faddat May 12, 2023
4e130d6
Update x/concentrated-liquidity/incentives_test.go
faddat May 15, 2023
9fe5b67
Update x/twap/export_test.go
faddat May 15, 2023
931cce4
Update x/twap/export_test.go
faddat May 15, 2023
ef8811b
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 15, 2023
6a6e558
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 16, 2023
07442dc
sync
faddat May 16, 2023
9732d6f
make all tests pass again
faddat May 16, 2023
32cdbf7
remove swap_test.go from skipped files
faddat May 16, 2023
14a97a9
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 16, 2023
9fe383e
standardize the type assertions
faddat May 17, 2023
d4f65b6
lint cli_test.go
faddat May 17, 2023
79094f2
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 17, 2023
45cda39
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 17, 2023
8427685
sync
faddat May 17, 2023
58d260f
fix tests
faddat May 17, 2023
b32c43a
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 17, 2023
f5e7d33
Merge remote-tracking branch 'origin/main' into dong/issue3849
faddat May 17, 2023
3273192
change linter settings
faddat May 17, 2023
86d210a
Merge branch 'dong/issue3849' into lint-all-tests
faddat May 17, 2023
dc15a1a
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 17, 2023
1e3d4b7
merge Dong's changes to x/gamm
faddat May 17, 2023
23f4650
Revert "Merge branch 'dong/issue3849' into lint-all-tests"
faddat May 17, 2023
01c7aca
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 17, 2023
80207d4
merge main, sync start gamm over again
faddat May 17, 2023
d4badba
bookmark
faddat May 18, 2023
f8f5136
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 18, 2023
508b973
save linting progress
faddat May 19, 2023
4bb0346
s. to suite
faddat May 19, 2023
e74f277
fully passing
faddat May 19, 2023
cd4ba9c
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 19, 2023
6c7694c
misc cleanup lets make sure we did not break e2e
faddat May 19, 2023
44a8475
deprecation notices
faddat May 19, 2023
cf79dbe
lint cliq bench test
faddat May 19, 2023
65e186e
cliq tests
faddat May 19, 2023
e7c8248
nolint the final two type assertions on chatgpt's advice
faddat May 19, 2023
c9caf07
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 19, 2023
964857d
sync
faddat May 19, 2023
1afd9a7
sync
faddat May 19, 2023
83c40d1
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 25, 2023
d949a20
adjust run time for golangci and autofixes after merging main and acc…
faddat May 25, 2023
906a746
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat May 30, 2023
1cd43c7
sync
faddat May 30, 2023
5296021
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jun 14, 2023
94726e3
sync
faddat Jun 14, 2023
509991f
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jun 28, 2023
118930a
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jun 28, 2023
77a7004
t.Helper() and b.Helper() + run golangci-lint ./... --fix
faddat Jun 28, 2023
4e58f86
remove unused function
faddat Jun 28, 2023
4e99ba6
remove unused functions, types, and fields in structs
faddat Jun 28, 2023
3cc8284
eliminate naked returns
faddat Jun 28, 2023
8241efe
eliminate naked returns
faddat Jun 28, 2023
4233d0f
suite -> s
faddat Jun 28, 2023
ad0213f
ineffectual assignments
faddat Jun 28, 2023
fa88191
misspelling and double imports
faddat Jun 28, 2023
908378e
cleanup (check errors and suite -> s)
faddat Jun 28, 2023
2838c57
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jun 30, 2023
5eb6ce2
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 5, 2023
03c0630
lint
faddat Jul 5, 2023
83bcdbb
merge succeded, this is cleanup of various lints
faddat Jul 5, 2023
30acea9
remove unused
faddat Jul 5, 2023
d4d12fb
make lint work in ci
faddat Jul 5, 2023
9d36046
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 6, 2023
b6aed98
autofixes
faddat Jul 6, 2023
6c9098a
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 6, 2023
12d7037
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 8, 2023
ed76fc5
fix foced type assertions and the "always zero" issue
faddat Jul 8, 2023
b6922a4
remove fuzzstate type
faddat Jul 8, 2023
f962856
rename swapAmountsMismatchErr swapAmountsMismatchError
faddat Jul 8, 2023
2c192df
linting v16 completed
faddat Jul 8, 2023
70e2cf6
fix randChangePercent (thanks @valardragon)
faddat Jul 8, 2023
a313b77
fix e2e tests
faddat Jul 8, 2023
92fe433
use t.Parallel correctly
faddat Jul 8, 2023
ca73d11
add a note about parallel e2e tests, and don't call t.Parallel()
faddat Jul 8, 2023
269bb4d
lengthen timeout for linter
faddat Jul 8, 2023
b21981e
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 13, 2023
de3762b
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 16, 2023
5412a54
lockuptypes
faddat Jul 16, 2023
d7fcf5b
bump linter
faddat Jul 16, 2023
d7474d5
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Jul 22, 2023
82f6550
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 3, 2023
194768b
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 3, 2023
bec5434
tidy
faddat Aug 3, 2023
bc248ae
sync and tidy
faddat Aug 3, 2023
98805e5
check errors
faddat Aug 3, 2023
df564ad
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 4, 2023
e9dbf9c
lint latest merge from main
faddat Aug 4, 2023
7aa9f0c
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 6, 2023
0b2c113
fix white space and double import
faddat Aug 6, 2023
c725bd1
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 8, 2023
87beb96
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 12, 2023
be8c21f
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 12, 2023
1f0e28d
lint tests with unparam
faddat Aug 12, 2023
434575d
remove another unused parameter
faddat Aug 12, 2023
f2e2b8c
Merge remote-tracking branch 'origin/main' into lint-all-tests
faddat Aug 16, 2023
aa81fb6
go work sync
faddat Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
run:
tests: false
tests: true
timeout: 5m
allow-parallel-runners: true
skip-files:
- x/gamm/keeper/grpc_query_test.go
- x/gamm/client/cli/query_test.go
- x/gamm/client/cli/cli_test.go
- x/gamm/keeper/swap_test.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these tests skipped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those tests are skipped because the code generation currently makes a whole lot of deprecated code. In order to fix that, we would just need to update the query generator I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, looking at this list, I'm not 100% sure about the swap test file. I can have another look at it tomorrow. Try to figure out why that one is there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have this reduced to just the generated queries.


output:
sort: true

linters:
disable-all: true
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v15/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (suite *UpgradeTestSuite) TestMigrateNextPoolIdAndCreatePool() {
gammKeeper := suite.App.GAMMKeeper
poolmanagerKeeper := suite.App.PoolManagerKeeper

nextPoolId := gammKeeper.GetNextPoolId(ctx)
nextPoolId := gammKeeper.GetNextPoolId(ctx) //nolint:staticcheck // we're using the deprecated version for testing.
suite.Require().Equal(expectedNextPoolId, nextPoolId)

// system under test.
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
// Environment variable name to skip the IBC tests
skipIBCEnv = "OSMOSIS_E2E_SKIP_IBC"
// Environment variable name to skip state sync testing
skipStateSyncEnv = "OSMOSIS_E2E_SKIP_STATE_SYNC"
skipStateSyncEnv = "OSMOSIS_E2E_SKIP_STATE_SYNC" //nolint:unused // this is used in the code
// Environment variable name to determine if this upgrade is a fork
forkHeightEnv = "OSMOSIS_E2E_FORK_HEIGHT"
// Environment variable name to skip cleaning up Docker resources in teardown
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() {
// Withdraw Position

// Withdraw Position parameters
var defaultLiquidityRemoval string = "1000"
defaultLiquidityRemoval := "1000"

chainA.WaitForNumHeights(2)

Expand Down
10 changes: 5 additions & 5 deletions tests/ibc-hooks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ func (suite *HooksTestSuite) SetupCrosschainSwaps(chainName Chain) (sdk.AccAddre
ctx := chain.GetContext()

// Configuring two prefixes for the same channel here. This is so that we can test bad acks when the receiver can't handle the receiving addr
msg := fmt.Sprintf(`{
msg := `{
"modify_bech32_prefixes": {
"operations": [
{"operation": "set", "chain_name": "osmosis", "prefix": "osmo"},
Expand All @@ -741,7 +741,7 @@ func (suite *HooksTestSuite) SetupCrosschainSwaps(chainName Chain) (sdk.AccAddre
]
}
}
`)
`
_, err = contractKeeper.Execute(ctx, registryAddr, owner, []byte(msg), sdk.NewCoins())
suite.Require().NoError(err)

Expand Down Expand Up @@ -957,7 +957,7 @@ func (suite *HooksTestSuite) TestUnwrapToken() {

contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(osmosisApp.WasmKeeper)

msg := fmt.Sprintf(`{
msg := `{
"modify_bech32_prefixes": {
"operations": [
{"operation": "set", "chain_name": "osmosis", "prefix": "osmo"},
Expand All @@ -967,7 +967,7 @@ func (suite *HooksTestSuite) TestUnwrapToken() {
]
}
}
`)
`
_, err := contractKeeper.Execute(ctx, registryAddr, owner, []byte(msg), sdk.NewCoins())
suite.Require().NoError(err)

Expand Down Expand Up @@ -1558,7 +1558,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() {
// Now the swwap can actually execute on A via the callback and generate a new packet with the swapped token to B
packet, err = ibctesting.ParsePacketFromEvents(res.GetEvents())
suite.Require().NoError(err)
res = suite.RelayPacketNoAck(packet, AtoB)
_ = suite.RelayPacketNoAck(packet, AtoB)

balanceToken0After := osmosisAppB.BankKeeper.GetBalance(suite.chainB.GetContext(), accountB, token0ACB)
suite.Require().Equal(int64(1000), balanceToken0.Amount.Sub(balanceToken0After.Amount).Int64())
Expand Down
6 changes: 3 additions & 3 deletions wasmbinding/query_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
proto "github.com/golang/protobuf/proto"
proto "github.com/golang/protobuf/proto" //nolint:staticcheck // we're intentionally using this deprecated package to be compatible with cosmos protos
"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/crypto/ed25519"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
suite.NoError(err)
},
requestData: func() []byte {
queryrequest := gammv2types.QuerySpotPriceRequest{
queryrequest := gammv2types.QuerySpotPriceRequest{ //nolint:staticcheck // we're intentionally using this deprecated package for testing
PoolId: 1,
BaseAssetDenom: "bar",
QuoteAssetDenom: "uosmo",
Expand All @@ -94,7 +94,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
return bz
},
checkResponseStruct: true,
responseProtoStruct: &gammv2types.QuerySpotPriceResponse{
responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ //nolint:staticcheck // we're intentionally using this deprecated package for testing
SpotPrice: sdk.NewDecWithPrec(5, 1).String(),
},
},
Expand Down
62 changes: 31 additions & 31 deletions x/concentrated-liquidity/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,14 @@ func (s *KeeperTestSuite) TestCalculateFeeGrowth() {
}
}

func (suite *KeeperTestSuite) TestGetInitialFeeGrowthOppositeDirectionOfLastTraversalForTick() {
func (s *KeeperTestSuite) TestGetInitialFeeGrowthOppositeDirectionOfLastTraversalForTick() {
const (
validPoolId = 1
)

initialPoolTickInt, err := math.PriceToTickRoundDown(DefaultAmt1.ToDec().Quo(DefaultAmt0.ToDec()), DefaultTickSpacing)
initialPoolTick := initialPoolTickInt.Int64()
suite.Require().NoError(err)
s.Require().NoError(err)

tests := map[string]struct {
poolId uint64
Expand Down Expand Up @@ -542,65 +542,65 @@ func (suite *KeeperTestSuite) TestGetInitialFeeGrowthOppositeDirectionOfLastTrav

for name, tc := range tests {
tc := tc
suite.Run(name, func() {
suite.SetupTest()
ctx := suite.Ctx
clKeeper := suite.App.ConcentratedLiquidityKeeper
s.Run(name, func() {
s.SetupTest()
ctx := s.Ctx
clKeeper := s.App.ConcentratedLiquidityKeeper

pool, err := clmodel.NewConcentratedLiquidityPool(validPoolId, ETH, USDC, DefaultTickSpacing, DefaultZeroSwapFee)
suite.Require().NoError(err)
s.Require().NoError(err)

// N.B.: we set the listener mock because we would like to avoid
// utilizing the production listeners. The production listeners
// are irrelevant in the context of the system under test. However,
// setting them up would require compromising being able to set up other
// edge case tests. For example, the test case where fee accumulator
// is not initialized.
suite.setListenerMockOnConcentratedLiquidityKeeper()
s.setListenerMockOnConcentratedLiquidityKeeper()

err = clKeeper.SetPool(ctx, &pool)
suite.Require().NoError(err)
s.Require().NoError(err)

if !tc.shouldAvoidCreatingAccum {
err = clKeeper.CreateFeeAccumulator(ctx, validPoolId)
suite.Require().NoError(err)
s.Require().NoError(err)

// Setup test position to make sure that tick is initialized
// We also set up uptime accums to ensure position creation works as intended
err = clKeeper.CreateUptimeAccumulators(ctx, validPoolId)
suite.Require().NoError(err)
suite.SetupDefaultPosition(validPoolId)
s.Require().NoError(err)
s.SetupDefaultPosition(validPoolId)

err = clKeeper.ChargeFee(ctx, validPoolId, tc.initialGlobalFeeGrowth)
suite.Require().NoError(err)
s.Require().NoError(err)
}

// System under test.
initialFeeGrowthOppositeDirectionOfLastTraversal, err := clKeeper.GetInitialFeeGrowthOppositeDirectionOfLastTraversalForTick(ctx, tc.poolId, tc.tick)

if tc.expectError != nil {
suite.Require().Error(err)
suite.Require().ErrorIs(err, tc.expectError)
s.Require().Error(err)
s.Require().ErrorIs(err, tc.expectError)
return
}
suite.Require().NoError(err)
suite.Require().Equal(tc.expectedInitialFeeGrowthOppositeDirectionOfLastTraversal, initialFeeGrowthOppositeDirectionOfLastTraversal)
s.Require().NoError(err)
s.Require().Equal(tc.expectedInitialFeeGrowthOppositeDirectionOfLastTraversal, initialFeeGrowthOppositeDirectionOfLastTraversal)
})
}
}

func (suite *KeeperTestSuite) TestChargeFee() {
func (s *KeeperTestSuite) TestChargeFee() {
// setup once at the beginning.
suite.SetupTest()
s.SetupTest()

ctx := suite.Ctx
clKeeper := suite.App.ConcentratedLiquidityKeeper
ctx := s.Ctx
clKeeper := s.App.ConcentratedLiquidityKeeper

// create fee accumulators with ids 1 and 2 but not 3.
err := clKeeper.CreateFeeAccumulator(ctx, 1)
suite.Require().NoError(err)
s.Require().NoError(err)
err = clKeeper.CreateFeeAccumulator(ctx, 2)
suite.Require().NoError(err)
s.Require().NoError(err)

tests := []struct {
name string
Expand Down Expand Up @@ -642,20 +642,20 @@ func (suite *KeeperTestSuite) TestChargeFee() {

for _, tc := range tests {
tc := tc
suite.Run(tc.name, func() {
s.Run(tc.name, func() {
// System under test.
err := clKeeper.ChargeFee(ctx, tc.poolId, tc.feeUpdate)

if tc.expectError != nil {
suite.Require().Error(err)
suite.Require().ErrorIs(err, tc.expectError)
s.Require().Error(err)
s.Require().ErrorIs(err, tc.expectError)
return
}
suite.Require().NoError(err)
s.Require().NoError(err)

feeAcumulator, err := clKeeper.GetFeeAccumulator(ctx, tc.poolId)
suite.Require().NoError(err)
suite.Require().Equal(tc.expectedGlobalGrowth, feeAcumulator.GetValue())
s.Require().NoError(err)
s.Require().Equal(tc.expectedGlobalGrowth, feeAcumulator.GetValue())
})
}
}
Expand Down Expand Up @@ -1518,7 +1518,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_LP() {
feesCollected := s.collectFeesAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionIdOne, sdk.NewCoins(), []string{USDC}, [][]sdk.Int{ticksActivatedAfterEachSwap})
expectedFeesTruncated := totalFeesExpected
for i, feeToken := range totalFeesExpected {
// We run expected fees through a cycle of divison and multiplication by liquidity to capture appropriate rounding behavior
// We run expected fees through a cycle of division and multiplication by liquidity to capture appropriate rounding behavior
expectedFeesTruncated[i] = sdk.NewCoin(feeToken.Denom, feeToken.Amount.ToDec().QuoTruncate(liquidity).MulTruncate(liquidity).TruncateInt())
}
s.Require().Equal(expectedFeesTruncated, feesCollected)
Expand Down Expand Up @@ -1555,7 +1555,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_LP() {
s.Require().Equal(expectesFeesCollected.String(), feesCollected.AmountOf(ETH).String())

// Create position in the default range 3.
positionIdThree, _, _, fullLiquidity, _, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick)
positionIdThree, _, _, _, _, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick)
s.Require().NoError(err)

collectedThree, err := s.App.ConcentratedLiquidityKeeper.CollectFees(ctx, owner, positionIdThree)
Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3738,7 +3738,7 @@ func (s *KeeperTestSuite) TestGetAllIncentiveRecordsForUptime() {
curUptimeRecords, err := clKeeper.GetAllIncentiveRecordsForUptime(s.Ctx, poolId, supportedUptime)
s.Require().NoError(err)

retrievedRecordsByUptime = append(retrievedRecordsByUptime, curUptimeRecords...)
retrievedRecordsByUptime = append(retrievedRecordsByUptime, curUptimeRecords...) //nolint:makezero,staticcheck // this is a test
faddat marked this conversation as resolved.
Show resolved Hide resolved
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
DefaultExponentOverlappingPositionUpperTick, _ = math.PriceToTickRoundDown(sdk.NewDec(4999), DefaultTickSpacing)
BAR = "bar"
FOO = "foo"
InsufficientFundsError = fmt.Errorf("insufficient funds")
ErrInsufficientFunds = fmt.Errorf("insufficient funds")
)

type KeeperTestSuite struct {
Expand All @@ -64,8 +64,8 @@ func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}

func (suite *KeeperTestSuite) SetupTest() {
suite.Setup()
func (s *KeeperTestSuite) SetupTest() {
s.Setup()
}

func (s *KeeperTestSuite) SetupDefaultPosition(poolId uint64) {
Expand Down
19 changes: 9 additions & 10 deletions x/concentrated-liquidity/lp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ func (s *KeeperTestSuite) TestWithdrawPosition() {
expectedRemainingLiquidity := liquidityCreated.Sub(config.liquidityAmount)

expectedFeesClaimed := sdk.NewCoins()
expectedIncentivesClaimed := sdk.NewCoins()
// Set the expected fees claimed to the amount of liquidity created since the global fee growth is 1.
// Fund the pool account with the expected fees claimed.
if expectedRemainingLiquidity.IsZero() {
Expand All @@ -535,7 +534,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() {
communityPoolBalanceBefore := s.App.BankKeeper.GetAllBalances(s.Ctx, s.App.AccountKeeper.GetModuleAddress(distributiontypes.ModuleName))

// Set expected incentives and fund pool with appropriate amount
expectedIncentivesClaimed = expectedIncentivesFromUptimeGrowth(defaultUptimeGrowth, liquidityCreated, tc.timeElapsed, defaultMultiplier)
expectedIncentivesClaimed := expectedIncentivesFromUptimeGrowth(defaultUptimeGrowth, liquidityCreated, tc.timeElapsed, defaultMultiplier)

// Fund full amount since forfeited incentives for the last position are sent to the community pool.
expectedFullIncentivesFromAllUptimes := expectedIncentivesFromUptimeGrowth(defaultUptimeGrowth, liquidityCreated, types.SupportedUptimes[len(types.SupportedUptimes)-1], defaultMultiplier)
Expand Down Expand Up @@ -1085,12 +1084,12 @@ func (s *KeeperTestSuite) TestSendCoinsBetweenPoolAndUser() {
"only asset0 is greater than sender has, position creation (user to pool)": {
coin0: sdk.NewCoin("eth", sdk.NewInt(100000000000000)),
coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)),
expectedErr: InsufficientFundsError,
expectedErr: ErrInsufficientFunds,
},
"only asset1 is greater than sender has, position creation (user to pool)": {
coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)),
coin1: sdk.NewCoin("usdc", sdk.NewInt(100000000000000)),
expectedErr: InsufficientFundsError,
expectedErr: ErrInsufficientFunds,
},
"asset0 and asset1 are positive, withdraw (pool to user)": {
coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)),
Expand All @@ -1111,13 +1110,13 @@ func (s *KeeperTestSuite) TestSendCoinsBetweenPoolAndUser() {
coin0: sdk.NewCoin("eth", sdk.NewInt(100000000000000)),
coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)),
poolToUser: true,
expectedErr: InsufficientFundsError,
expectedErr: ErrInsufficientFunds,
},
"only asset1 is greater than sender has, withdraw (pool to user)": {
coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)),
coin1: sdk.NewCoin("usdc", sdk.NewInt(100000000000000)),
poolToUser: true,
expectedErr: InsufficientFundsError,
expectedErr: ErrInsufficientFunds,
},
"asset0 is negative - error": {
coin0: sdk.Coin{Denom: "eth", Amount: sdk.NewInt(1000000).Neg()},
Expand Down Expand Up @@ -1152,9 +1151,9 @@ func (s *KeeperTestSuite) TestSendCoinsBetweenPoolAndUser() {
// store pool interface
poolI, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, 1)
s.Require().NoError(err)
concentratedPool, ok := poolI.(types.ConcentratedPoolExtension)
concentratedPool, ok := poolI.(types.ConcentratedPoolExtension) //nolint:gosimple // need to check if poolI is a ConcentratedPoolExtension
faddat marked this conversation as resolved.
Show resolved Hide resolved
if !ok {
s.FailNow("poolI is not a ConcentratedPoolExtension")
s.FailNow("poolI is not a *ConcentratedPoolExtension")
}

// fund pool address and user address
Expand Down Expand Up @@ -1384,13 +1383,13 @@ func (s *KeeperTestSuite) TestUpdatePosition() {
// validate if pool liquidity has been updated properly
poolI, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, tc.poolId)
s.Require().NoError(err)
concentratedPool, ok := poolI.(types.ConcentratedPoolExtension)
concentratedPool, ok := poolI.(types.ConcentratedPoolExtension) //nolint:gosimple // need to check if poolI is a ConcentratedPoolExtension
if !ok {
s.FailNow("poolI is not a ConcentratedPoolExtension")
}
s.Require().Equal(tc.expectedPoolLiquidity, concentratedPool.GetLiquidity())

// Test that liquidity update time was succesfully changed.
// Test that liquidity update time was successfully changed.
s.Require().Equal(expectedUpdateTime, poolI.GetLastLiquidityUpdate())
}
})
Expand Down
Loading