Skip to content

Commit

Permalink
remove duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Dec 17, 2024
1 parent 51fe361 commit 375b089
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import (
"errors"
"fmt"
"math/rand"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -2496,71 +2493,3 @@ func TestABCI_Proposal_FailReCheckTx(t *testing.T) {
require.NotEmpty(t, res.TxResults[0].Events)
require.True(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res))
}

func TestABCI_HaltChain(t *testing.T) {
logger := defaultLogger()
db := dbm.NewMemDB()
name := t.Name()

testCases := []struct {
name string
haltHeight uint64
haltTime uint64
blockHeight int64
blockTime int64
expHalt bool
}{
{"default", 0, 0, 10, 0, false},
{"halt-height-edge", 10, 0, 10, 0, false},
{"halt-height", 10, 0, 11, 0, true},
{"halt-time-edge", 0, 10, 1, 10, false},
{"halt-time", 0, 10, 1, 11, true},
}

sigs := make(chan os.Signal, 5)
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.expHalt {
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
}

defer func() {
rec := recover()
signal.Stop(sigs)
var err error
if rec != nil {
err = rec.(error)
}
if !tc.expHalt {
require.NoError(t, err)
} else {
// ensure that we received the correct signals
require.Equal(t, syscall.SIGINT, <-sigs)
require.Equal(t, syscall.SIGTERM, <-sigs)
require.Equal(t, len(sigs), 0)

// Check our error message.
require.Error(t, err)
require.True(t, strings.HasPrefix(err.Error(), "halt application"))
}
}()

app := NewBaseapp(
name, logger, db, nil,
SetHaltHeight(tc.haltHeight),
SetHaltTime(tc.haltTime),
)

app.InitChain(abci.RequestInitChain{
InitialHeight: tc.blockHeight,
})

app.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
Height: tc.blockHeight,
Time: time.Unix(tc.blockTime, 0),
},
})
})
}
}

0 comments on commit 375b089

Please sign in to comment.