diff --git a/PENDING.md b/PENDING.md index abb97988c4..12b1949b10 100644 --- a/PENDING.md +++ b/PENDING.md @@ -109,6 +109,7 @@ BUG FIXES * Gaia CLI (`gaiacli`) * [cli] [\#1997](https://github.com/cosmos/cosmos-sdk/issues/1997) Handle panics gracefully when `gaiacli stake {delegation,unbond}` fail to unmarshal delegation. + * [cli] [\#2265](https://github.com/cosmos/cosmos-sdk/issues/2265) Fix JSON formatting of the `gaiacli send` command. * Gaia @@ -118,5 +119,6 @@ BUG FIXES * [ledger] [\#2064](https://github.com/cosmos/cosmos-sdk/issues/2064) Fix inability to sign and send transactions via the LCD by loading a Ledger device at runtime. * [\#2158](https://github.com/cosmos/cosmos-sdk/issues/2158) Fix non-deterministic ordering of validator iteration when slashing in `gov EndBlocker` + * [simulation] \#1924 Make simulation stop on SIGTERM * Tendermint diff --git a/client/context/query.go b/client/context/query.go index ae801ac91b..d108f80fa5 100644 --- a/client/context/query.go +++ b/client/context/query.go @@ -255,11 +255,11 @@ func (ctx CLIContext) ensureBroadcastTx(txBytes []byte) error { type toJSON struct { Height int64 TxHash string - Response string + Response abci.ResponseDeliverTx } if ctx.Logger != nil { - resJSON := toJSON{res.Height, res.Hash.String(), fmt.Sprintf("%+v", res.DeliverTx)} + resJSON := toJSON{res.Height, res.Hash.String(), res.DeliverTx} bz, err := ctx.Codec.MarshalJSON(resJSON) if err != nil { return err diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index d8d242e5b7..5cdf293716 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" cmn "github.com/tendermint/tendermint/libs/common" @@ -112,8 +113,17 @@ func TestGaiaCLIGasAuto(t *testing.T) { require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf("steak").Int64()) // Enable auto gas - success = executeWrite(t, fmt.Sprintf("gaiacli send %v --gas=0 --amount=10steak --to=%s --from=foo", flags, barAddr), app.DefaultKeyPass) + success, stdout, _ := executeWriteRetStdStreams(t, fmt.Sprintf("gaiacli send %v --json --gas=0 --amount=10steak --to=%s --from=foo", flags, barAddr), app.DefaultKeyPass) require.True(t, success) + // check that gas wanted == gas used + cdc := app.MakeCodec() + jsonOutput := struct { + Height int64 + TxHash string + Response abci.ResponseDeliverTx + }{} + require.Nil(t, cdc.UnmarshalJSON([]byte(stdout), &jsonOutput)) + require.Equal(t, jsonOutput.Response.GasWanted, jsonOutput.Response.GasUsed) tests.WaitForNextNBlocksTM(2, port) // Check state has changed accordingly fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %s %v", fooAddr, flags)) diff --git a/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index b71200b36a..fc010d76a3 100644 --- a/x/mock/simulation/random_simulate_blocks.go +++ b/x/mock/simulation/random_simulate_blocks.go @@ -6,7 +6,9 @@ import ( "math" "math/rand" "os" + "os/signal" "sort" + "syscall" "testing" "time" @@ -81,6 +83,16 @@ func SimulateFromSeed( header := abci.Header{Height: 0, Time: timestamp} opCount := 0 + // Setup code to catch SIGTERM's + c := make(chan os.Signal) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + go func() { + <-c + fmt.Printf("Exiting early due to SIGTERM, on block %d, operation %d\n", header.Height, opCount) + DisplayEvents(events) + os.Exit(128 + int(syscall.SIGTERM)) + }() + var pastTimes []time.Time var pastVoteInfos [][]abci.VoteInfo