aboutsummaryrefslogtreecommitdiffstats
path: root/core/nodeset-cache_test.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-15 15:26:30 +0800
committerGitHub <noreply@github.com>2018-10-15 15:26:30 +0800
commit3c1b208090f4455344fade2a218d332300d76458 (patch)
treedcb86be8233c596325d9f379f0f653d4990bc634 /core/nodeset-cache_test.go
parent508cf09792a35f0129df9b04efa471074e61a36f (diff)
downloadtangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar.gz
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar.bz2
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar.lz
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar.xz
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.tar.zst
tangerine-consensus-3c1b208090f4455344fade2a218d332300d76458.zip
core: Add NodeSetCacheInterface (#203)
Diffstat (limited to 'core/nodeset-cache_test.go')
-rw-r--r--core/nodeset-cache_test.go39
1 files changed, 17 insertions, 22 deletions
diff --git a/core/nodeset-cache_test.go b/core/nodeset-cache_test.go
index 73f0dee..0b69ee3 100644
--- a/core/nodeset-cache_test.go
+++ b/core/nodeset-cache_test.go
@@ -19,31 +19,31 @@ package core
import (
"testing"
+ "time"
"github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core/crypto"
"github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa"
+ "github.com/dexon-foundation/dexon-consensus-core/core/test"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
"github.com/stretchr/testify/suite"
)
-type testGov struct {
+type nsIntf struct {
s *NodeSetCacheTestSuite
crs common.Hash
curKeys []crypto.PublicKey
}
-func (g *testGov) Configuration(round uint64) (cfg *types.Config) {
+func (g *nsIntf) Configuration(round uint64) (cfg *types.Config) {
return &types.Config{
NotarySetSize: 7,
DKGSetSize: 7,
NumChains: 4,
}
}
-func (g *testGov) CRS(round uint64) (b common.Hash) { return g.crs }
-func (g *testGov) ProposeCRS([]byte) {}
-func (g *testGov) NotifyRoundHeight(round, height uint64) {}
-func (g *testGov) NodeSet(round uint64) []crypto.PublicKey {
+func (g *nsIntf) CRS(round uint64) (b common.Hash) { return g.crs }
+func (g *nsIntf) NodeSet(round uint64) []crypto.PublicKey {
// Randomly generating keys, and check them for verification.
g.curKeys = []crypto.PublicKey{}
for i := 0; i < 10; i++ {
@@ -53,32 +53,27 @@ func (g *testGov) NodeSet(round uint64) []crypto.PublicKey {
}
return g.curKeys
}
-func (g *testGov) AddDKGComplaint(_ uint64, _ *types.DKGComplaint) {}
-func (g *testGov) DKGComplaints(
- round uint64) (cs []*types.DKGComplaint) {
- return
-}
-func (g *testGov) AddDKGMasterPublicKey(
- _ uint64, _ *types.DKGMasterPublicKey) {
-}
-func (g *testGov) DKGMasterPublicKeys(
- round uint64) (keys []*types.DKGMasterPublicKey) {
- return
-}
-func (g *testGov) AddDKGFinalize(_ uint64, _ *types.DKGFinalize) {}
-func (g *testGov) IsDKGFinal(round uint64) bool { return true }
type NodeSetCacheTestSuite struct {
suite.Suite
}
+func (s *NodeSetCacheTestSuite) TestGovernanceIntf() {
+ // NodeSetCacheInterface should let Governance implement it.
+ var gov Governance
+ gov, err := test.NewGovernance(7, 250*time.Millisecond)
+ s.Require().NoError(err)
+ _, ok := gov.(NodeSetCacheInterface)
+ s.True(ok)
+}
+
func (s *NodeSetCacheTestSuite) TestBasicUsage() {
var (
- gov = &testGov{
+ nsIntf = &nsIntf{
s: s,
crs: common.NewRandomHash(),
}
- cache = NewNodeSetCache(gov)
+ cache = NewNodeSetCache(nsIntf)
req = s.Require()
)