aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/app_test.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-03-20 17:29:22 +0800
committerGitHub <noreply@github.com>2019-03-20 17:29:22 +0800
commitc852eda00f781abafaab2b41d2c1a85fe9d3177f (patch)
tree931680bf76590c4bdb74c247582f213c17db9274 /core/test/app_test.go
parent448935829700500ecf512b9e0a6437cbb63504b3 (diff)
downloadtangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.gz
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.zst
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.zip
core: reset DKG (#502)
* Allow utils.NodeSetCache to purge by rounds. * Purge utils.NodeSetCache when DKG reset. * Add a utils.RoundEvent handler to abort all previous running DKG * Fix test.App hangs in BlockDelivered when utils.RoundEvent is attached. ValidateNextRound is a blocking call and would block test.App.BlockDelivered.
Diffstat (limited to 'core/test/app_test.go')
-rw-r--r--core/test/app_test.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/core/test/app_test.go b/core/test/app_test.go
index c83aaf6..138f803 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -309,15 +309,15 @@ func (s *AppTestSuite) TestAttachedWithRoundEvent() {
1900, 2019, core.ConfigRoundShift)
s.Require().NoError(err)
// Register a handler to collects triggered events.
- var evts []evtParamToCheck
+ evts := make(chan evtParamToCheck, 2)
rEvt.Register(func(params []utils.RoundEventParam) {
for _, p := range params {
- evts = append(evts, evtParamToCheck{
+ evts <- evtParamToCheck{
round: p.Round,
reset: p.Reset,
height: p.BeginHeight,
crs: p.CRS,
- })
+ }
}
})
// Setup App instance.
@@ -336,18 +336,16 @@ func (s *AppTestSuite) TestAttachedWithRoundEvent() {
// Deliver blocks from height=2020 to height=2081.
deliver(0, 0, 2019)
deliver(19, 2020, 2091)
- s.Require().Len(evts, 2)
- s.Require().Equal(evts[0], evtParamToCheck{19, 2, 2100, gov.CRS(19)})
- s.Require().Equal(evts[1], evtParamToCheck{20, 0, 2200, gov.CRS(20)})
+ 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.
deliver(19, 2092, 2199)
deliver(20, 2200, 2291)
- s.Require().Len(evts, 3)
- s.Require().Equal(evts[2], evtParamToCheck{21, 0, 2300, gov.CRS(21)})
+ s.Require().Equal(<-evts, evtParamToCheck{21, 0, 2300, gov.CRS(21)})
// Deliver blocks from height=2282 to height=2381.
deliver(20, 2292, 2299)
deliver(21, 2300, 2391)
- s.Require().Equal(evts[3], evtParamToCheck{22, 0, 2400, gov.CRS(22)})
+ s.Require().Equal(<-evts, evtParamToCheck{22, 0, 2400, gov.CRS(22)})
}
func TestApp(t *testing.T) {