Skip to content

Commit

Permalink
test(gamm): CalcJoinPoolNoSwapShares, CalcJoinPoolShares, CalcExitPoo…
Browse files Browse the repository at this point in the history
…lCoinsFromShares state alteration tests (#3378)

(cherry picked from commit c24b1e1)
  • Loading branch information
p0mvn authored and mergify[bot] committed Nov 16, 2022
1 parent 559368a commit 86fceaf
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion x/gamm/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
gocontext "context"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"

"github.com/osmosis-labs/osmosis/v12/app/apptesting"
Expand All @@ -24,6 +25,19 @@ func (s *QueryTestSuite) SetupSuite() {
}

func (s *QueryTestSuite) TestQueriesNeverAlterState() {
var (
fooDenom = apptesting.DefaultPoolAssets[0].Token.Denom
barDenom = apptesting.DefaultPoolAssets[1].Token.Denom
bazDenom = apptesting.DefaultPoolAssets[2].Token.Denom
uosmoDenom = apptesting.DefaultPoolAssets[3].Token.Denom

basicValidTokensIn = sdk.NewCoins(
sdk.NewCoin(fooDenom, sdk.OneInt()),
sdk.NewCoin(barDenom, sdk.OneInt()),
sdk.NewCoin(bazDenom, sdk.OneInt()),
sdk.NewCoin(uosmoDenom, sdk.OneInt()))
)

testCases := []struct {
name string
query string
Expand Down Expand Up @@ -63,7 +77,7 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() {
{
"Query spot price",
"/osmosis.gamm.v1beta1.Query/SpotPrice",
&types.QuerySpotPriceRequest{PoolId: 1, BaseAssetDenom: "foo", QuoteAssetDenom: "bar"},
&types.QuerySpotPriceRequest{PoolId: 1, BaseAssetDenom: fooDenom, QuoteAssetDenom: barDenom},
&types.QuerySpotPriceResponse{},
},
{
Expand All @@ -84,6 +98,24 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() {
&types.QueryTotalSharesRequest{PoolId: 1},
&types.QueryTotalSharesResponse{},
},
{
"Query estimate for join pool shares with no swap",
"/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares",
&types.QueryCalcJoinPoolNoSwapSharesRequest{PoolId: 1, TokensIn: basicValidTokensIn},
&types.QueryCalcJoinPoolNoSwapSharesResponse{},
},
{
"Query estimate for join pool shares with no swap",
"/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares",
&types.QueryCalcJoinPoolSharesRequest{PoolId: 1, TokensIn: basicValidTokensIn},
&types.QueryCalcJoinPoolSharesResponse{},
},
{
"Query exit pool coins from shares",
"/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares",
&types.QueryCalcExitPoolCoinsFromSharesRequest{PoolId: 1, ShareInAmount: sdk.OneInt()},
&types.QueryCalcExitPoolCoinsFromSharesResponse{},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 86fceaf

Please sign in to comment.