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