diff options
Diffstat (limited to 'integration_test')
-rw-r--r-- | integration_test/consensus_test.go | 10 | ||||
-rw-r--r-- | integration_test/round-event_test.go | 29 |
2 files changed, 34 insertions, 5 deletions
diff --git a/integration_test/consensus_test.go b/integration_test/consensus_test.go index 5131465..70e6c1f 100644 --- a/integration_test/consensus_test.go +++ b/integration_test/consensus_test.go @@ -180,7 +180,7 @@ func (s *ConsensusTestSuite) syncBlocksWithSomeNode( } syncerHeight = b.Finalization.Height + 1 compactionChainBlocks = append(compactionChainBlocks, &b) - if len(compactionChainBlocks) >= 100 { + if len(compactionChainBlocks) >= 20 { if syncBlocks() { break } @@ -340,9 +340,9 @@ func (s *ConsensusTestSuite) TestSync() { req = s.Require() peerCount = 4 dMoment = time.Now().UTC() - untilRound = uint64(5) - stopRound = uint64(3) - aliveRound = uint64(1) + untilRound = uint64(7) + stopRound = uint64(5) + aliveRound = uint64(4) errChan = make(chan error, 100) ) prvKeys, pubKeys, err := test.NewKeys(peerCount) @@ -442,7 +442,7 @@ ReachAlive: select { case <-runnerCtx.Done(): break SyncLoop - case <-time.After(2 * time.Second): + case <-time.After(4 * time.Second): } } }() 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)) } |