diff --git a/PENDING.md b/PENDING.md index bfcbcd978130..5701d732cbd3 100644 --- a/PENDING.md +++ b/PENDING.md @@ -114,5 +114,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/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index 3f7f5ed40f3a..b7a911e06549 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" @@ -76,6 +78,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 pastSigningValidators [][]abci.SigningValidator