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

style: remove unused code in tests #5108

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 0 additions & 3 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const (
skipUpgradeEnv = "OSMOSIS_E2E_SKIP_UPGRADE"
// 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"
Copy link
Member

@p0mvn p0mvn May 8, 2023

Choose a reason for hiding this comment

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

This is being used here, we should restore this:

if s.skipStateSync {

Copy link
Member Author

@faddat faddat May 8, 2023

Choose a reason for hiding this comment

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

hmmmm I thought it was used. Any idea how toget one's editor to see that? Or ci for that matter?

basically I made that particular change, cause I noticed that doing so did not cause anything else to break. Adding er back now.

Copy link
Member Author

Choose a reason for hiding this comment

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

aha! env vars for e2e -- this explains what I saw....

Copy link
Member

Choose a reason for hiding this comment

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

Ahh I see now. I think this was intended to be used in place of the hardcoded value here:

if str := os.Getenv("OSMOSIS_E2E_SKIP_STATE_SYNC"); len(str) > 0 {

but was never replaced. So your editor was correct to catch this as unused

Copy link
Member

Choose a reason for hiding this comment

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

Not going to block this PR on this change but we can replace the hardcoded value with skipStateSyncEnv in the future.

Thanks @faddat

// 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 All @@ -35,7 +33,6 @@ type IntegrationTestSuite struct {
skipUpgrade bool
skipIBC bool
skipStateSync bool
forkHeight int
}

func TestIntegrationTestSuite(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,6 @@ func (s *IntegrationTestSuite) TestGeometricTWAP() {
denomB = "stake" // 2_000_000 stake

minAmountOut = "1"

epochIdentifier = "day"
)

chainA := s.configurer.GetChainConfig(0)
Expand Down
3 changes: 0 additions & 3 deletions tests/ibc-hooks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ type HooksTestSuite struct {
pathAB *ibctesting.Path
pathAC *ibctesting.Path
pathBC *ibctesting.Path
pathBA *ibctesting.Path
pathCA *ibctesting.Path
pathCB *ibctesting.Path
Comment on lines -51 to -53
Copy link
Member

Choose a reason for hiding this comment

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

imo it might make sense to leave these, just in case they might be useful in the future

// This is used to test cw20s. It will only get assigned in the cw20 test
pathCW20 *ibctesting.Path
}
Expand Down
37 changes: 0 additions & 37 deletions wasmbinding/test/custom_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ import (

"github.com/osmosis-labs/osmosis/v15/app"
"github.com/osmosis-labs/osmosis/v15/wasmbinding/bindings"
"github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/balancer"
)

// we must pay this many uosmo for every pool we create
var poolFee int64 = 1000000000

var defaultFunds = sdk.NewCoins(
sdk.NewInt64Coin("uatom", 333000000),
sdk.NewInt64Coin("uosmo", 555000000+2*poolFee),
sdk.NewInt64Coin("ustar", 999000000),
)

func SetupCustomApp(t *testing.T, addr sdk.AccAddress) (*app.OsmosisApp, sdk.Context) {
Expand Down Expand Up @@ -95,13 +85,6 @@ func queryCustom(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, contrac
require.NoError(t, err)
}

func assertValidShares(t *testing.T, shares wasmvmtypes.Coin, poolID uint64) {
// sanity check: check the denom and ensure at least 18 decimal places
denom := fmt.Sprintf("gamm/pool/%d", poolID)
require.Equal(t, denom, shares.Denom)
require.Greater(t, len(shares.Amount), 18)
}

func storeReflectCode(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress) {
govKeeper := osmosis.GovKeeper
wasmCode, err := os.ReadFile("../testdata/osmo_reflect.wasm")
Expand Down Expand Up @@ -143,23 +126,3 @@ func fundAccount(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sd
)
require.NoError(t, err)
}

func preparePool(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress, funds []sdk.Coin) uint64 {
var assets []balancer.PoolAsset
for _, coin := range funds {
assets = append(assets, balancer.PoolAsset{
Weight: sdk.NewInt(100),
Token: coin,
})
}

poolParams := balancer.PoolParams{
SwapFee: sdk.NewDec(0),
ExitFee: sdk.NewDec(0),
}

msg := balancer.NewMsgCreateBalancerPool(addr, poolParams, assets, "")
poolId, err := osmosis.PoolManagerKeeper.CreatePool(ctx, &msg)
require.NoError(t, err)
return poolId
}
1 change: 0 additions & 1 deletion x/concentrated-liquidity/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (s *KeeperTestSuite) TestGetFeeGrowthOutside() {
globalFeeGrowth sdk.DecCoin

expectedFeeGrowthOutside sdk.DecCoins
invalidTick bool
expectedError bool
}

Expand Down
35 changes: 1 addition & 34 deletions x/concentrated-liquidity/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ var (
testAddressThree = sdk.MustAccAddressFromBech32("osmo1qwexv7c6sm95lwhzn9027vyu2ccneaqad4w8ka")
testAddressFour = sdk.MustAccAddressFromBech32("osmo14hcxlnwlqtq75ttaxf674vk6mafspg8xwgnn53")

testAccumOne = "testAccumOne"

// Note: lexicographic order is denomFour, denomOne, denomThree, denomTwo
testDenomOne = "denomOne"
testDenomTwo = "denomTwo"
Expand Down Expand Up @@ -113,9 +111,7 @@ var (
MinUptime: testUptimeFour,
}

testQualifyingDepositsOne = sdk.NewInt(50)
testQualifyingDepositsTwo = sdk.NewInt(100)
testQualifyingDepositsThree = sdk.NewInt(399)
testQualifyingDepositsOne = sdk.NewInt(50)

defaultBalancerAssets = []balancer.PoolAsset{
{Weight: sdk.NewInt(1), Token: sdk.NewCoin("foo", sdk.NewInt(100))},
Expand All @@ -124,8 +120,6 @@ var (
defaultConcentratedAssets = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)), sdk.NewCoin("bar", sdk.NewInt(100)))
defaultBalancerPoolParams = balancer.PoolParams{SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDec(0)}
invalidPoolId = uint64(10)

defaultAuthorizedUptimes = []time.Duration{time.Nanosecond}
)

type ExpectedUptimes struct {
Expand Down Expand Up @@ -215,14 +209,6 @@ func chargeIncentive(incentiveRecord types.IncentiveRecord, timeElapsed time.Dur
return incentiveRecord
}

// emittedIncentives returns the amount of incentives emitted by incentiveRecord over timeElapsed.
// It uses the same logic as chargeIncentive for calculating this amount.
func emittedIncentives(incentiveRecord types.IncentiveRecord, timeElapsed time.Duration) sdk.Dec {
secToNanoSec := int64(1000000000)
incentivesEmitted := incentiveRecord.IncentiveRecordBody.EmissionRate.Mul(sdk.NewDec(int64(timeElapsed)).Quo(sdk.NewDec(secToNanoSec)))
return incentivesEmitted
}

// Helper for adding a predetermined amount to each global uptime accum in clPool
func addToUptimeAccums(ctx sdk.Context, poolId uint64, clKeeper *cl.Keeper, addValues []sdk.DecCoins) error {
poolUptimeAccumulators, err := clKeeper.GetUptimeAccumulators(ctx, poolId)
Expand Down Expand Up @@ -252,18 +238,6 @@ func addDecCoinsArray(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoi
return finalDecCoinArray, nil
}

func createIncentiveRecord(incentiveDenom string, remainingAmt, emissionRate sdk.Dec, startTime time.Time, minUpTime time.Duration) types.IncentiveRecord {
return types.IncentiveRecord{
IncentiveDenom: incentiveDenom,
IncentiveRecordBody: types.IncentiveRecordBody{
RemainingAmount: remainingAmt,
EmissionRate: emissionRate,
StartTime: startTime,
},
MinUptime: minUpTime,
}
}

func withDenom(record types.IncentiveRecord, denom string) types.IncentiveRecord {
record.IncentiveDenom = denom

Expand Down Expand Up @@ -759,16 +733,11 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() {
longestLockableDuration := lockableDurations[len(lockableDurations)-1]
type updateAccumToNow struct {
poolId uint64
accumUptime time.Duration
qualifyingLiquidity sdk.Dec
timeElapsed time.Duration
poolIncentiveRecords []types.IncentiveRecord
canonicalBalancerPoolAssets []balancer.PoolAsset

isInvalidPoolId bool
isInvalidBalancerPool bool
expectedResult sdk.DecCoins
expectedUptimeDeltas []sdk.DecCoins
expectedIncentiveRecords []types.IncentiveRecord
expectedError error
}
Expand Down Expand Up @@ -1206,7 +1175,6 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthInsideRange() {
globalUptimeGrowth []sdk.DecCoins

expectedUptimeGrowthInside []sdk.DecCoins
invalidTick bool
expectedError bool
}

Expand Down Expand Up @@ -1534,7 +1502,6 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthOutsideRange() {
globalUptimeGrowth []sdk.DecCoins

expectedUptimeGrowthOutside []sdk.DecCoins
invalidTick bool
expectedError bool
}

Expand Down
13 changes: 5 additions & 8 deletions x/concentrated-liquidity/lp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

type lpTest struct {
poolId uint64
owner sdk.AccAddress
currentTick sdk.Int
lowerTick int64
upperTick int64
Expand Down Expand Up @@ -1371,13 +1370,11 @@ func (s *KeeperTestSuite) TestUpdatePosition() {
}

func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() {
var (
sqrt = func(x int64) sdk.Dec {
sqrt, err := sdk.NewDec(x).ApproxSqrt()
s.Require().NoError(err)
return sqrt
}
)
sqrt := func(x int64) sdk.Dec {
sqrt, err := sdk.NewDec(x).ApproxSqrt()
s.Require().NoError(err)
return sqrt
}

type sendTest struct {
amount0Desired sdk.Int
Expand Down
1 change: 0 additions & 1 deletion x/concentrated-liquidity/position_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() {
joinTime time.Time
positionId uint64
liquidityDelta sdk.Dec
liquidityIn sdk.Dec
}

tests := []struct {
Expand Down
5 changes: 0 additions & 5 deletions x/concentrated-liquidity/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ var (
)

func (s *KeeperTestSuite) TestParseFullTickFromBytes() {
const (
emptyKeySeparator = ""
invalidKeySeparator = "-"
)

var (
cdc = s.App.AppCodec()

Expand Down
4 changes: 0 additions & 4 deletions x/gamm/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
poolmanagertypes "github.com/osmosis-labs/osmosis/v15/x/poolmanager/types"

"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
)
Expand All @@ -23,9 +22,6 @@ var testAddresses = osmoutils.CreateRandomAccounts(3)

type IntegrationTestSuite struct {
suite.Suite

cfg network.Config
network *network.Network
}

func TestNewCreatePoolCmd(t *testing.T) {
Expand Down
5 changes: 1 addition & 4 deletions x/gamm/keeper/pool_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ var (
SwapFee: defaultSwapFee,
ExitFee: defaultZeroExitFee,
}
defaultStableSwapPoolParams = stableswap.PoolParams{
SwapFee: defaultSwapFee,
ExitFee: defaultZeroExitFee,
}

defaultScalingFactor = []uint64{1, 1}
defaultFutureGovernor = ""

Expand Down
11 changes: 1 addition & 10 deletions x/gamm/keeper/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ import (
)

var (
defaultPoolAssetsStableSwap = sdk.Coins{
sdk.NewCoin("atom", sdk.NewInt(100)),
sdk.NewCoin("osmo", sdk.NewInt(100)),
}
defaultPoolParamsStableSwap = stableswap.PoolParams{
SwapFee: sdk.NewDecWithPrec(1, 2),
ExitFee: sdk.ZeroDec(),
}
defaultPoolId = uint64(1)
defaultAcctFundsStableSwap sdk.Coins = sdk.NewCoins(
sdk.NewCoin("uosmo", sdk.NewInt(10000000000)),
sdk.NewCoin("atom", sdk.NewInt(100)),
sdk.NewCoin("osmo", sdk.NewInt(100)),
)
defaultPoolId = uint64(1)
)

// import (
Expand Down
11 changes: 0 additions & 11 deletions x/gamm/pool-models/balancer/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var ymlAssetTest = []balancer.PoolAsset{
{
Weight: sdk.NewInt(200),
Token: sdk.NewCoin("test2", sdk.NewInt(50000)),
},
{
Weight: sdk.NewInt(100),
Token: sdk.NewCoin("test1", sdk.NewInt(10000)),
},
}

func TestPoolJson(t *testing.T) {
var poolId uint64 = 10

Expand Down
1 change: 0 additions & 1 deletion x/gamm/pool-models/balancer/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ func (suite *BalancerTestSuite) TestBalancerCalculateAmountOutAndIn_InverseRelat
func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) {
type testcase struct {
initialPoolOut int64
initialPoolIn int64
initialWeightOut int64
tokenOut int64
initialWeightIn int64
Expand Down
13 changes: 0 additions & 13 deletions x/gamm/pool-models/balancer/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/store/rootmulti"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/v15/x/gamm/pool-models/balancer"
Expand All @@ -29,15 +25,6 @@ func createTestPool(t *testing.T, swapFee, exitFee sdk.Dec, poolAssets ...balanc
return &pool
}

func createTestContext(t *testing.T) sdk.Context {
db := dbm.NewMemDB()
logger := log.NewNopLogger()

ms := rootmulti.NewStore(db, logger)

return sdk.NewContext(ms, tmtypes.Header{}, false, logger)
}

func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares sdk.Int) {
allowedErrRatioDec, err := sdk.NewDecFromStr(allowedErrRatio)
require.NoError(t, err)
Expand Down
2 changes: 0 additions & 2 deletions x/incentives/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (

"github.com/cosmos/cosmos-sdk/types/query"

"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/v15/x/incentives/types"
)

var testAddresses = osmoutils.CreateRandomAccounts(3)

func TestGetCmdGauges(t *testing.T) {
desc, _ := GetCmdGauges()
Expand Down
5 changes: 0 additions & 5 deletions x/incentives/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ func TestAuthzMsg(t *testing.T) {
coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))
someDate := time.Date(1, 1, 1, 1, 1, 1, 1, time.UTC)

const (
mockGranter string = "cosmos1abc"
mockGrantee string = "cosmos1xyz"
)

testCases := []struct {
name string
incentivesMsg sdk.Msg
Expand Down
5 changes: 0 additions & 5 deletions x/lockup/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@ func TestAuthzMsg(t *testing.T) {
addr1 := sdk.AccAddress(pk1.Address()).String()
coin := sdk.NewCoin("denom", sdk.NewInt(1))

const (
mockGranter string = "cosmos1abc"
mockGrantee string = "cosmos1xyz"
)

testCases := []struct {
name string
msg sdk.Msg
Expand Down
Loading