From 934905b45b1713a95a49737b9eff60987a46d333 Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 12 Aug 2024 14:13:17 +0200 Subject: [PATCH] refactor halt --- baseapp/abci.go | 4 ++-- baseapp/abci_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index d2d87a5cf562..49470e0af771 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -914,10 +914,10 @@ func (app *BaseApp) FinalizeBlock(req *abci.FinalizeBlockRequest) (res *abci.Fin func (app *BaseApp) checkHalt(height int64, time time.Time) error { var halt bool switch { - case app.haltHeight > 0 && uint64(height) > app.haltHeight: + case app.haltHeight > 0 && uint64(height) >= app.haltHeight: halt = true - case app.haltTime > 0 && time.Unix() > int64(app.haltTime): + case app.haltTime > 0 && time.Unix() >= int64(app.haltTime): halt = true } diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index b7fb67fad216..43b2c06d550e 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -2257,9 +2257,11 @@ func TestABCI_HaltChain(t *testing.T) { 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-height-edge", 11, 0, 10, 0, false}, + {"halt-height-equal", 10, 0, 10, 0, true}, + {"halt-height", 10, 0, 10, 0, true}, + {"halt-time-edge", 0, 11, 1, 10, false}, + {"halt-time-equal", 0, 10, 1, 10, true}, {"halt-time", 0, 10, 1, 11, true}, }