Skip to content

Commit

Permalink
Merge branch 'main' into gnad/add-allowed-packet
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Dec 14, 2023
2 parents 66bb1e7 + 549fd90 commit aa3b5a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions e2e/tests/wasm/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
"testing"
"time"

testifysuite "github.com/stretchr/testify/suite"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
testifysuite "github.com/stretchr/testify/suite"

upgradetypes "cosmossdk.io/x/upgrade/types"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
Expand Down
19 changes: 2 additions & 17 deletions e2e/testsuite/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package testsuite
import (
"bytes"
"encoding/hex"
"fmt"

"github.com/cosmos/gogoproto/jsonpb"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -35,6 +34,7 @@ import (
solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
localhost "github.com/cosmos/ibc-go/v8/modules/light-clients/09-localhost"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
simappparams "github.com/cosmos/ibc-go/v8/testing/simapp/params"
)

Expand Down Expand Up @@ -101,22 +101,7 @@ func UnmarshalMsgResponses(txResp sdk.TxResponse, msgs ...codec.ProtoMarshaler)
return err
}

var txMsgData sdk.TxMsgData
if err := cdc.Unmarshal(bz, &txMsgData); err != nil {
return err
}

if len(msgs) != len(txMsgData.MsgResponses) {
return fmt.Errorf("expected %d message responses but got %d", len(msgs), len(txMsgData.MsgResponses))
}

for i, msg := range msgs {
if err := cdc.Unmarshal(txMsgData.MsgResponses[i].Value, msg); err != nil {
return err
}
}

return nil
return ibctesting.UnmarshalMsgResponses(cdc, bz, msgs...)
}

// MustProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded
Expand Down
24 changes: 24 additions & 0 deletions testing/utils.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package ibctesting

import (
"fmt"
"math/rand"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

abci "github.com/cometbft/cometbft/abci/types"
cmttypes "github.com/cometbft/cometbft/types"
)
Expand Down Expand Up @@ -33,3 +37,23 @@ func GenerateString(length uint) string {
}
return string(bytes)
}

// UnmarshalMsgResponses parse out msg responses from a transaction result
func UnmarshalMsgResponses(cdc codec.Codec, data []byte, msgs ...codec.ProtoMarshaler) error {
var txMsgData sdk.TxMsgData
if err := cdc.Unmarshal(data, &txMsgData); err != nil {
return err
}

if len(msgs) != len(txMsgData.MsgResponses) {
return fmt.Errorf("expected %d message responses but got %d", len(msgs), len(txMsgData.MsgResponses))
}

for i, msg := range msgs {
if err := cdc.Unmarshal(txMsgData.MsgResponses[i].Value, msg); err != nil {
return err
}
}

return nil
}

0 comments on commit aa3b5a1

Please sign in to comment.