Commit 9ffdc37c authored by Nicolas Lara's avatar Nicolas Lara
Browse files

make format

parent 64320349
Showing with 57 additions and 49 deletions
+57 -49
......@@ -2,15 +2,16 @@ package app
import (
"fmt"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"io"
"net/http"
"os"
"path/filepath"
"strings"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
......
......@@ -44,8 +44,7 @@ var (
// ----------------------------------------------------------------------------
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
func NewAppModuleBasic() AppModuleBasic {
return AppModuleBasic{}
......
......@@ -9,8 +9,10 @@ import (
"github.com/osmosis-labs/osmosis/v10/x/gamm/types"
)
var _ types.GammHooks = &gammhook{}
var _ epochtypes.EpochHooks = &epochhook{}
var (
_ types.GammHooks = &gammhook{}
_ epochtypes.EpochHooks = &epochhook{}
)
type epochhook struct {
k Keeper
......
......@@ -12,8 +12,10 @@ import (
"github.com/osmosis-labs/osmosis/v10/x/gamm/twap/types"
)
var defaultUniV2Coins = sdk.NewCoins(sdk.NewInt64Coin("token/B", 1_000_000_000), sdk.NewInt64Coin("token/A", 1_000_000_000))
var baseTime = time.Unix(1257894000, 0).UTC()
var (
defaultUniV2Coins = sdk.NewCoins(sdk.NewInt64Coin("token/B", 1_000_000_000), sdk.NewInt64Coin("token/A", 1_000_000_000))
baseTime = time.Unix(1257894000, 0).UTC()
)
type TestSuite struct {
apptesting.KeeperTestHelper
......
......@@ -23,8 +23,7 @@ var (
_ module.AppModuleBasic = AppModuleBasic{}
)
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
func (AppModuleBasic) Name() string { return types.ModuleName }
......
......@@ -84,12 +84,14 @@ func (s *TestSuite) TestGetAllMostRecentRecordsForPool() {
recordsToSet: []types.TwapRecord{
newEmptyPriceRecord(1, baseTime, "tokenB", "tokenA"),
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB"),
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA")},
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA"),
},
poolId: 1,
expectedRecords: []types.TwapRecord{
newEmptyPriceRecord(1, baseTime, "tokenB", "tokenA"),
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA"),
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB")},
newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB"),
},
},
}
......@@ -136,40 +138,50 @@ func (s *TestSuite) TestGetRecordAtOrBeforeTime() {
"rev at latest (exact)": {[]types.TwapRecord{baseRecord}, defaultRevInputAt(baseTime), baseRecord, true},
"get latest (exact) w/ past entries": {
[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(baseTime), baseRecord, false},
[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(baseTime), baseRecord, false,
},
"get entry (exact) w/ a subsequent entry": {
[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tMin1), tMin1Record, false},
[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tMin1), tMin1Record, false,
},
"get sandwitched entry (exact)": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultInputAt(baseTime), baseRecord, false},
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultInputAt(baseTime), baseRecord, false,
},
"rev sandwitched entry (exact)": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultRevInputAt(baseTime), baseRecord, true},
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultRevInputAt(baseTime), baseRecord, true,
},
"get future": {[]types.TwapRecord{baseRecord}, defaultInputAt(tPlus1), baseRecord, false},
"get future w/ past entries": {[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tPlus1), baseRecord, false},
"get in between entries (2 entry)": {
[]types.TwapRecord{tMin1Record, baseRecord},
defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false},
defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false,
},
"get in between entries (3 entry)": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record},
defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false},
defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false,
},
"get in between entries (3 entry) #2": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record},
defaultInputAt(baseTime.Add(time.Millisecond)), baseRecord, false},
defaultInputAt(baseTime.Add(time.Millisecond)), baseRecord, false,
},
"query too old": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record},
defaultInputAt(baseTime.Add(-time.Second * 2)),
baseRecord, true},
baseRecord, true,
},
"non-existent pool ID": {
[]types.TwapRecord{tMin1Record, baseRecord, tPlus1Record},
wrongPoolIdInputAt(baseTime), baseRecord, true},
wrongPoolIdInputAt(baseTime), baseRecord, true,
},
"pool2 record get": {
recordsToSet: []types.TwapRecord{newEmptyPriceRecord(2, baseTime, "tokenB", "tokenA")},
input: wrongPoolIdInputAt(baseTime),
expectedRecord: newEmptyPriceRecord(2, baseTime, "tokenB", "tokenA"),
expErr: false},
expErr: false,
},
}
for name, test := range tests {
s.Run(name, func() {
......
......@@ -16,8 +16,10 @@ import (
lockupkeeper "github.com/osmosis-labs/osmosis/v10/x/lockup/keeper"
)
var _ porttypes.Middleware = &IBCModule{}
var _ porttypes.ICS4Wrapper = &ICS4Middleware{}
var (
_ porttypes.Middleware = &IBCModule{}
_ porttypes.ICS4Wrapper = &ICS4Middleware{}
)
type ICS4Middleware struct {
channel porttypes.ICS4Wrapper
......
......@@ -3,13 +3,14 @@ package ibc_rate_limit
import (
"encoding/json"
"fmt"
"strings"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
"github.com/osmosis-labs/osmosis/v10/x/ibc-rate-limit/types"
"strings"
)
func CheckRateLimits(ctx sdk.Context, wasmKeeper *wasmkeeper.Keeper, msgType, contractParam, channelValue, sourceChannel string, sender sdk.AccAddress, amount string) error {
......
package osmosisibctesting
import (
"time"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v3/testing"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
"github.com/cosmos/ibc-go/v3/testing/simapp/helpers"
"github.com/osmosis-labs/osmosis/v10/app"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"time"
)
type TestChain struct {
......@@ -56,7 +57,6 @@ func SignAndDeliver(
txCfg client.TxConfig, app *baseapp.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, _ := helpers.GenTx(
txCfg,
msgs,
......
......@@ -2,6 +2,8 @@ package osmosisibctesting
import (
"fmt"
"io/ioutil"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
......@@ -9,7 +11,6 @@ import (
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
"github.com/osmosis-labs/osmosis/v10/x/ibc-rate-limit/types"
"github.com/stretchr/testify/suite"
"io/ioutil"
)
func (chain *TestChain) StoreContractCode(suite *suite.Suite) {
......
......@@ -2,6 +2,7 @@ package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
......@@ -54,7 +55,6 @@ func validateContractAddress(i interface{}) error {
bech32, err := sdk.AccAddressFromBech32(v)
if err != nil {
return err
}
err = sdk.VerifyAddressFormat(bech32)
......
......@@ -134,7 +134,6 @@ func (suite *KeeperTestSuite) TestCreateGauge_Fee() {
}
func (suite *KeeperTestSuite) TestAddToGauge_Fee() {
tests := []struct {
name string
accountBalanceToFund sdk.Coins
......
......@@ -44,8 +44,7 @@ var (
// ----------------------------------------------------------------------------
// Implements the AppModuleBasic interface for the module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
// NewAppModuleBasic creates a new AppModuleBasic struct.
func NewAppModuleBasic() AppModuleBasic {
......
......@@ -47,8 +47,7 @@ var (
// ----------------------------------------------------------------------------
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
func NewAppModuleBasic() AppModuleBasic {
return AppModuleBasic{}
......
......@@ -16,9 +16,7 @@ const (
DeveloperVestingAmount = developerVestingAmount
)
var (
GetProportions = getProportions
)
var GetProportions = getProportions
func (k Keeper) DistributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion sdk.Dec) (sdk.Int, error) {
return k.distributeToModule(ctx, recipientModule, mintedCoin, proportion)
......
......@@ -158,9 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeMintedCoin() {
mintAmount = 10000
)
var (
params = types.DefaultParams()
)
params := types.DefaultParams()
tests := []struct {
name string
......
......@@ -40,8 +40,7 @@ var (
_ module.AppModuleSimulation = AppModule{}
)
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
// Name returns the pool-incentives module's name.
func (AppModuleBasic) Name() string { return types.ModuleName }
......
......@@ -514,7 +514,6 @@ func (suite *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() {
refreshed := suite.App.BankKeeper.GetBalance(suite.Ctx, intermediaryAcc.GetAccAddress(), sdk.DefaultBondDenom)
suite.Require().True(refreshed.IsZero())
}
})
}
}
......
......@@ -43,8 +43,7 @@ var (
// ----------------------------------------------------------------------------
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
func NewAppModuleBasic() AppModuleBasic {
return AppModuleBasic{}
......
......@@ -41,8 +41,7 @@ var (
// ----------------------------------------------------------------------------
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}
func NewAppModuleBasic() AppModuleBasic {
return AppModuleBasic{}
......
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