Skip to content

Commit

Permalink
style: remove unused code in tests (#5108)
Browse files Browse the repository at this point in the history
* unused code in tests

* re-add skip state sync
  • Loading branch information
faddat authored May 8, 2023
1 parent 7cc0090 commit 7ec4c2f
Show file tree
Hide file tree
Showing 27 changed files with 12 additions and 202 deletions.
1 change: 0 additions & 1 deletion tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 @@ -1469,8 +1469,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 @@ -49,9 +49,6 @@ type HooksTestSuite struct {
pathAB *ibctesting.Path
pathAC *ibctesting.Path
pathBC *ibctesting.Path
pathBA *ibctesting.Path
pathCA *ibctesting.Path
pathCB *ibctesting.Path
// 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 @@ -260,7 +260,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 @@ -28,8 +28,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 @@ -112,9 +110,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 @@ -123,8 +119,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 @@ -214,14 +208,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 @@ -251,18 +237,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 @@ -758,16 +732,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 @@ -1205,7 +1174,6 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthInsideRange() {
globalUptimeGrowth []sdk.DecCoins

expectedUptimeGrowthInside []sdk.DecCoins
invalidTick bool
expectedError bool
}

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

expectedUptimeGrowthOutside []sdk.DecCoins
invalidTick bool
expectedError bool
}

Expand Down
1 change: 0 additions & 1 deletion 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
1 change: 0 additions & 1 deletion x/concentrated-liquidity/position_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 @@ -21,10 +21,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 @@ -16,20 +16,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 @@ -585,7 +585,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
12 changes: 0 additions & 12 deletions x/poolmanager/types/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,15 @@ const (
)

var (
defaultPoolInitAmount = sdk.NewInt(10_000_000_000)
twentyFiveBaseUnitsAmount = sdk.NewInt(25_000_000)

fooCoin = sdk.NewCoin(foo, defaultPoolInitAmount)
barCoin = sdk.NewCoin(bar, defaultPoolInitAmount)
bazCoin = sdk.NewCoin(baz, defaultPoolInitAmount)
uosmoCoin = sdk.NewCoin(uosmo, defaultPoolInitAmount)

// Note: These are iniialized in such a way as it makes
// it easier to reason about the test cases.
fooBarCoins = sdk.NewCoins(fooCoin, barCoin)
fooBarPoolId = uint64(1)
fooBazCoins = sdk.NewCoins(fooCoin, bazCoin)
fooBazPoolId = fooBarPoolId + 1
fooUosmoCoins = sdk.NewCoins(fooCoin, uosmoCoin)
fooUosmoPoolId = fooBazPoolId + 1
barBazCoins = sdk.NewCoins(barCoin, bazCoin)
barBazPoolId = fooUosmoPoolId + 1
barUosmoCoins = sdk.NewCoins(barCoin, uosmoCoin)
barUosmoPoolId = barBazPoolId + 1
bazUosmoCoins = sdk.NewCoins(bazCoin, uosmoCoin)
bazUosmoPoolId = barUosmoPoolId + 1

// Amount in default routes
Expand Down
Loading

0 comments on commit 7ec4c2f

Please sign in to comment.