Fix tests
This commit is contained in:
parent
6135912e53
commit
da400156c3
|
@ -3,12 +3,13 @@ package baseapp
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
@ -937,7 +938,7 @@ func TestSimulateTx(t *testing.T) {
|
|||
require.True(t, queryResult.IsOK(), queryResult.Log)
|
||||
|
||||
var simRes sdk.SimulationResponse
|
||||
require.NoError(t, json.Unmarshal(queryResult.Value, &simRes))
|
||||
require.NoError(t, jsonpb.Unmarshal(strings.NewReader(string(queryResult.Value)), &simRes))
|
||||
|
||||
require.Equal(t, gInfo, simRes.GasInfo)
|
||||
require.Equal(t, result.Log, simRes.Result.Log)
|
||||
|
|
|
@ -2,11 +2,13 @@ package tx
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
|
@ -277,7 +279,7 @@ func CalculateGas(
|
|||
}
|
||||
|
||||
var simRes sdk.SimulationResponse
|
||||
if err := json.Unmarshal(bz, &simRes); err != nil {
|
||||
if err := jsonpb.Unmarshal(strings.NewReader(string(bz)), &simRes); err != nil {
|
||||
return sdk.SimulationResponse{}, 0, err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package tx_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/std"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
|
@ -20,12 +20,12 @@ func TestCalculateGas(t *testing.T) {
|
|||
if wantErr {
|
||||
return nil, 0, errors.New("query failed")
|
||||
}
|
||||
simRes := sdk.SimulationResponse{
|
||||
simRes := &sdk.SimulationResponse{
|
||||
GasInfo: sdk.GasInfo{GasUsed: gasUsed, GasWanted: gasUsed},
|
||||
Result: &sdk.Result{Data: []byte("tx data"), Log: "log"},
|
||||
}
|
||||
|
||||
bz, err := json.Marshal(simRes)
|
||||
bz, err := codec.ProtoMarshalJSON(simRes)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue