Skip to content

Commit

Permalink
Handle error on interchaintest. (#135)
Browse files Browse the repository at this point in the history
* Handle error on interchaintest.

* Fix query not found host zone config.

* Refactor import by goimports.
  • Loading branch information
tnv1 authored Jan 24, 2024
1 parent fb6075a commit aaab69d
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 32 deletions.
3 changes: 2 additions & 1 deletion tests/interchaintest/chain_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package interchaintest
import (
"context"
"fmt"
"testing"

sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
"testing"

"github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
Expand Down
1 change: 1 addition & 0 deletions tests/interchaintest/feeabs/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package feeabs

import (
"encoding/base64"

abcitypes "github.com/cometbft/cometbft/abci/types"
)

Expand Down
3 changes: 2 additions & 1 deletion tests/interchaintest/feeabs/osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"path/filepath"
"strconv"

"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
)

func CreatePool(c *cosmos.CosmosChain, ctx context.Context, keyName string, params cosmos.OsmosisPoolParams) (string, error) {
Expand Down
9 changes: 5 additions & 4 deletions tests/interchaintest/feeabs/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strconv"
"time"

"github.com/avast/retry-go/v4"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types"
Expand All @@ -13,10 +18,6 @@ import (
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
"os"
"path/filepath"
"strconv"
"time"
)

func getFullNode(c *cosmos.CosmosChain) *cosmos.ChainNode {
Expand Down
1 change: 1 addition & 0 deletions tests/interchaintest/feeabs/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package feeabs
import (
"context"
"encoding/json"

"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
)

Expand Down
6 changes: 4 additions & 2 deletions tests/interchaintest/feeabs/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package feeabs

import "github.com/cosmos/cosmos-sdk/types"
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

type HostChainFeeAbsConfigResponse struct {
HostChainConfig HostChainFeeAbsConfig `json:"host_chain_config"`
Expand All @@ -21,6 +23,6 @@ type AddHostZoneProposalType struct {
}

type QueryFeeabsModuleBalacesResponse struct {
Balances types.Coins
Balances sdk.Coins
Address string
}
23 changes: 12 additions & 11 deletions tests/interchaintest/host_zone_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package interchaintest
import (
"context"
"fmt"
feeabsCli "github.com/notional-labs/fee-abstraction/tests/interchaintest/feeabs"
"testing"

feeabsCli "github.com/notional-labs/fee-abstraction/tests/interchaintest/feeabs"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/stretchr/testify/require"
)
Expand All @@ -28,7 +28,9 @@ func TestHostZoneProposal(t *testing.T) {
err = feeabs.VoteOnProposalAllValidators(ctx, "1", cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, _ := feeabs.Height(ctx)
height, err := feeabs.Height(ctx)
require.NoError(t, err)

_, err = cosmos.PollForProposalStatus(ctx, feeabs, height, height+10, "1", cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

Expand All @@ -48,7 +50,9 @@ func TestHostZoneProposal(t *testing.T) {
err = feeabs.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, _ = feeabs.Height(ctx)
height, err = feeabs.Height(ctx)
require.NoError(t, err)

_, err = cosmos.PollForProposalStatus(ctx, feeabs, height, height+10, "2", cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

Expand All @@ -68,16 +72,13 @@ func TestHostZoneProposal(t *testing.T) {
err = feeabs.VoteOnProposalAllValidators(ctx, "3", cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, _ = feeabs.Height(ctx)
height, err = feeabs.Height(ctx)
require.NoError(t, err)

response, err := cosmos.PollForProposalStatus(ctx, feeabs, height, height+10, "3", cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")
fmt.Printf("response: %s\n", response)

config, err = feeabsCli.QueryHostZoneConfigWithDenom(feeabs, ctx, "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9")
require.Equal(t, config, &feeabsCli.HostChainFeeAbsConfigResponse{HostChainConfig: feeabsCli.HostChainFeeAbsConfig{
IbcDenom: "",
OsmosisPoolTokenDenomIn: "",
PoolId: "",
Frozen: false,
}})
_, err = feeabsCli.QueryHostZoneConfigWithDenom(feeabs, ctx, "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9")
require.Error(t, err) // not found
}
1 change: 0 additions & 1 deletion tests/interchaintest/ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"cosmossdk.io/math"
sdktypes "github.com/cosmos/cosmos-sdk/types"

transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
Expand Down
17 changes: 11 additions & 6 deletions tests/interchaintest/packet_foward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package interchaintest

import (
"context"
"cosmossdk.io/math"
"fmt"
sdktypes "github.com/cosmos/cosmos-sdk/types"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
feeabsCli "github.com/notional-labs/fee-abstraction/tests/interchaintest/feeabs"
"os"
"path"
"testing"

"cosmossdk.io/math"
sdktypes "github.com/cosmos/cosmos-sdk/types"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
feeabsCli "github.com/notional-labs/fee-abstraction/tests/interchaintest/feeabs"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
Expand Down Expand Up @@ -143,6 +143,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
// send ibc token to feeabs module account
gaiaHeight, err := gaia.Height(ctx)
require.NoError(t, err)

feeabsModule, err := feeabsCli.QueryModuleAccountBalances(feeabs, ctx)
require.NoError(t, err)
dstAddress := feeabsModule.Address
Expand Down Expand Up @@ -176,7 +177,9 @@ func TestPacketForwardMiddleware(t *testing.T) {
err = feeabs.VoteOnProposalAllValidators(ctx, paramTx.ProposalID, cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, _ := feeabs.Height(ctx)
height, err := feeabs.Height(ctx)
require.NoError(t, err)

_, err = cosmos.PollForProposalStatus(ctx, feeabs, height, height+10, paramTx.ProposalID, cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

Expand All @@ -186,7 +189,9 @@ func TestPacketForwardMiddleware(t *testing.T) {
err = feeabs.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, _ = feeabs.Height(ctx)
height, err = feeabs.Height(ctx)
require.NoError(t, err)

_, err = cosmos.PollForProposalStatus(ctx, feeabs, height, height+10, "2", cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks")

Expand Down
7 changes: 2 additions & 5 deletions tests/interchaintest/setup.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package interchaintest

import (
"cosmossdk.io/math"
"encoding/json"
"fmt"
"os"
"strings"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/icza/dyno"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos/wasm"

feeabstype "github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/types"

// "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos/wasm"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos/wasm"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
)

Expand Down
2 changes: 1 addition & 1 deletion x/feeabs/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewQuerier(k Keeper) Querier {
return Querier{Keeper: k}
}

// OsmosisSpotPrice return spot price of pair Osmo/nativeToken
// OsmosisArithmeticTwap return spot price of pair Osmo/nativeToken
func (q Querier) OsmosisArithmeticTwap(goCtx context.Context, req *types.QueryOsmosisArithmeticTwapRequest) (*types.QueryOsmosisArithmeticTwapResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
Expand Down

0 comments on commit aaab69d

Please sign in to comment.