aboutsummaryrefslogtreecommitdiffstats
path: root/integration_test/round-event_test.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-03-16 10:07:08 +0800
committerGitHub <noreply@github.com>2019-03-16 10:07:08 +0800
commit50c9419ba04ed44854fdb1afc1ef2e865be9876f (patch)
tree2acafd84bdb61d54da5621c29c3914986df45b65 /integration_test/round-event_test.go
parentb02fa5ee430cff9dafc9d9c399099a88d554a083 (diff)
downloaddexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar.gz
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar.bz2
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar.lz
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar.xz
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.tar.zst
dexon-consensus-50c9419ba04ed44854fdb1afc1ef2e865be9876f.zip
core, syncer: integrate utils.RoundEvent (#490)
Diffstat (limited to 'integration_test/round-event_test.go')
-rw-r--r--integration_test/round-event_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/integration_test/round-event_test.go b/integration_test/round-event_test.go
index f8cac26..8201bfe 100644
--- a/integration_test/round-event_test.go
+++ b/integration_test/round-event_test.go
@@ -221,6 +221,35 @@ func (s *RoundEventTestSuite) TestLastPeriod() {
s.Require().Equal(length, uint64(200))
}
+func (s *RoundEventTestSuite) TestTriggerInitEvent() {
+ gov := s.prepareGov()
+ s.Require().NoError(gov.State().RequestChange(test.StateChangeRoundLength,
+ uint64(100)))
+ gov.CatchUpWithRound(0)
+ s.Require().NoError(gov.State().RequestChange(test.StateChangeRoundLength,
+ uint64(200)))
+ gov.CatchUpWithRound(1)
+ // Prepare utils.RoundEvent, starts from genesis.
+ rEvt, err := utils.NewRoundEvent(
+ context.Background(), gov, s.logger, 0, 0, 0, core.ConfigRoundShift)
+ s.Require().NoError(err)
+ // Register a handler to collects triggered events.
+ var evts []evtParamToCheck
+ rEvt.Register(func(params []utils.RoundEventParam) {
+ for _, p := range params {
+ evts = append(evts, evtParamToCheck{
+ round: p.Round,
+ reset: p.Reset,
+ height: p.BeginHeight,
+ crs: p.CRS,
+ })
+ }
+ })
+ rEvt.TriggerInitEvent()
+ s.Require().Len(evts, 1)
+ s.Require().Equal(evts[0], evtParamToCheck{0, 0, 0, gov.CRS(0)})
+}
+
func TestRoundEvent(t *testing.T) {
suite.Run(t, new(RoundEventTestSuite))
}