aboutsummaryrefslogtreecommitdiffstats
path: root/core/test
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-03-22 14:04:30 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-22 14:04:30 +0800
commit49c47180328c06eaeaca9176c2819b55bd75464f (patch)
treef374aaa06404b9054ef85e0a9088900db7bbfce7 /core/test
parent672d245243b6b85040f96e6638628b86975e9a1b (diff)
downloaddexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar.gz
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar.bz2
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar.lz
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar.xz
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.tar.zst
dexon-consensus-49c47180328c06eaeaca9176c2819b55bd75464f.zip
core: height event handlers are not called (#509)
* Make utils.RoundEvent.ValidateNextRound non-blocking * Make NotifyHeight called blockingly * Trigger all height event handlers that should be triggered by initBlock * Fixup: forget the syncer part
Diffstat (limited to 'core/test')
-rw-r--r--core/test/app.go13
-rw-r--r--core/test/app_test.go3
2 files changed, 6 insertions, 10 deletions
diff --git a/core/test/app.go b/core/test/app.go
index 12b2047..d704698 100644
--- a/core/test/app.go
+++ b/core/test/app.go
@@ -108,18 +108,13 @@ func NewApp(initRound uint64, gov *Governance, rEvt *utils.RoundEvent) (
app.state = gov.State()
}
if rEvt != nil {
- app.hEvt.RegisterHeight(
- utils.GetNextRoundValidationHeight(rEvt.LastPeriod()),
- func(h uint64) {
- rEvt.ValidateNextRound(h)
- })
rEvt.Register(func(evts []utils.RoundEventParam) {
app.hEvt.RegisterHeight(
evts[len(evts)-1].NextRoundValidationHeight(),
- func(h uint64) {
- rEvt.ValidateNextRound(h)
- })
+ utils.RoundEventRetryHandlerGenerator(rEvt, app.hEvt),
+ )
})
+ rEvt.TriggerInitEvent()
}
return app
}
@@ -265,7 +260,7 @@ func (app *App) BlockDelivered(blockHash common.Hash, pos types.Position,
}
}
}()
- go app.hEvt.NotifyHeight(result.Height)
+ app.hEvt.NotifyHeight(result.Height)
}
// GetLatestDeliveredPosition would return the latest position of delivered
diff --git a/core/test/app_test.go b/core/test/app_test.go
index 138f803..e06b758 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -309,7 +309,7 @@ func (s *AppTestSuite) TestAttachedWithRoundEvent() {
1900, 2019, core.ConfigRoundShift)
s.Require().NoError(err)
// Register a handler to collects triggered events.
- evts := make(chan evtParamToCheck, 2)
+ evts := make(chan evtParamToCheck, 3)
rEvt.Register(func(params []utils.RoundEventParam) {
for _, p := range params {
evts <- evtParamToCheck{
@@ -336,6 +336,7 @@ func (s *AppTestSuite) TestAttachedWithRoundEvent() {
// Deliver blocks from height=2020 to height=2081.
deliver(0, 0, 2019)
deliver(19, 2020, 2091)
+ s.Require().Equal(<-evts, evtParamToCheck{19, 1, 2000, gov.CRS(19)})
s.Require().Equal(<-evts, evtParamToCheck{19, 2, 2100, gov.CRS(19)})
s.Require().Equal(<-evts, evtParamToCheck{20, 0, 2200, gov.CRS(20)})
// Deliver blocks from height=2082 to height=2281.