aboutsummaryrefslogtreecommitdiffstats
path: root/dex/helper_test.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-09-25 16:53:56 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:21:31 +0800
commit94bb940818d9b5c6d654da14f13918e65cf84623 (patch)
tree27c40976f1a1ee43ea717673e771b7eef9e93729 /dex/helper_test.go
parent42e9b9b25d21f40f7d4ebfbb0e7cbca0f1ade6d4 (diff)
downloadgo-tangerine-94bb940818d9b5c6d654da14f13918e65cf84623.tar.gz
go-tangerine-94bb940818d9b5c6d654da14f13918e65cf84623.tar.zst
go-tangerine-94bb940818d9b5c6d654da14f13918e65cf84623.zip
dex: implement notary node info propagation and management mechanism
Diffstat (limited to 'dex/helper_test.go')
-rw-r--r--dex/helper_test.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/dex/helper_test.go b/dex/helper_test.go
index 13d2bbaec..8836b31da 100644
--- a/dex/helper_test.go
+++ b/dex/helper_test.go
@@ -46,6 +46,28 @@ var (
testBank = crypto.PubkeyToAddress(testBankKey.PublicKey)
)
+// testP2PServer is a fake, helper p2p server for testing purposes.
+type testP2PServer struct {
+ added chan *discover.Node
+ removed chan *discover.Node
+}
+
+func (s *testP2PServer) Self() *discover.Node {
+ return &discover.Node{}
+}
+
+func (s *testP2PServer) AddNotaryPeer(node *discover.Node) {
+ if s.added != nil {
+ s.added <- node
+ }
+}
+
+func (s *testP2PServer) RemoveNotaryPeer(node *discover.Node) {
+ if s.removed != nil {
+ s.removed <- node
+ }
+}
+
// newTestProtocolManager creates a new protocol manager for testing purposes,
// with the given number of blocks already known, and potential notification
// channels for different events.
@@ -70,7 +92,7 @@ func newTestProtocolManager(mode downloader.SyncMode, blocks int, generator func
if err != nil {
return nil, nil, err
}
- pm.Start(1000)
+ pm.Start(&testP2PServer{}, 1000)
return pm, db, nil
}