diff --git a/consensus/polybft/extra_fork_base.go b/consensus/polybft/extra_fork_base.go index 805d9cce01..604a49f733 100644 --- a/consensus/polybft/extra_fork_base.go +++ b/consensus/polybft/extra_fork_base.go @@ -9,6 +9,13 @@ import ( "github.com/umbracle/fastrlp" ) +func init() { + // for tests + forkManagerInstance.RegisterFork(forkmanager.InitialFork) + _ = forkManagerInstance.RegisterHandler(forkmanager.InitialFork, extraHandler, &ExtraHandlerBase{}) + _ = forkManagerInstance.ActivateFork(forkmanager.InitialFork, 0) +} + const extraHandler forkmanager.HandlerDesc = "extra" type IExtraHandler interface { diff --git a/consensus/polybft/polybft.go b/consensus/polybft/polybft.go index 5a59b92ef9..9f4974aaa0 100644 --- a/consensus/polybft/polybft.go +++ b/consensus/polybft/polybft.go @@ -366,11 +366,15 @@ func ForkManagerFactory(forks *chain.Forks) error { fm := forkmanager.GetInstance() // Register handlers here - _ = fm.RegisterHandler(forkmanager.InitialFork, extraHandler, &ExtraHandlerBase{}) - _ = fm.RegisterHandler(chain.MyFirstFork, extraHandler, &ExtraHandlerMyFirstFork{}) - _ = fm.RegisterHandler(chain.MySecondFork, extraHandler, &ExtraHandlerMySecondFork{}) + if err := fm.RegisterHandler(forkmanager.InitialFork, extraHandler, &ExtraHandlerBase{}); err != nil { + return err + } - return nil + if err := fm.RegisterHandler(chain.MyFirstFork, extraHandler, &ExtraHandlerMyFirstFork{}); err != nil { + return err + } + + return fm.RegisterHandler(chain.MySecondFork, extraHandler, &ExtraHandlerMySecondFork{}) } // Initialize initializes the consensus (e.g. setup data)