aboutsummaryrefslogtreecommitdiffstats
path: root/core/utils/nodeset-cache_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/utils/nodeset-cache_test.go
parent448935829700500ecf512b9e0a6437cbb63504b3 (diff)
downloadtangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.gz
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.bz2
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.lz
tangerine-consensus-c852eda00f781abafaab2b41d2c1a85fe9d3177f.tar.xz
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/utils/nodeset-cache_test.go')
-rw-r--r--core/utils/nodeset-cache_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/utils/nodeset-cache_test.go b/core/utils/nodeset-cache_test.go
index fe905cf..45d30a7 100644
--- a/core/utils/nodeset-cache_test.go
+++ b/core/utils/nodeset-cache_test.go
@@ -138,6 +138,24 @@ func (s *NodeSetCacheTestSuite) TestTouch() {
req.True(exists)
}
+func (s *NodeSetCacheTestSuite) TestPurge() {
+ var (
+ nsIntf = &nsIntf{
+ s: s,
+ crs: common.NewRandomHash(),
+ }
+ cache = NewNodeSetCache(nsIntf)
+ req = s.Require()
+ )
+ err := cache.Touch(1)
+ req.NoError(err)
+ _, exist := cache.get(1)
+ req.True(exist)
+ cache.Purge(1)
+ _, exist = cache.get(1)
+ req.False(exist)
+}
+
func TestNodeSetCache(t *testing.T) {
suite.Run(t, new(NodeSetCacheTestSuite))
}