diff options
author | Sonic <sonic@cobinhood.com> | 2018-09-25 16:53:56 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:48 +0800 |
commit | b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3 (patch) | |
tree | 14170b1371d8ec4c74cdf8d5a616860eb8b07dc7 /dex/helper_test.go | |
parent | 8c2ff681e2d5718b5b91fa41707eb64423fdd306 (diff) | |
download | dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar.gz dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar.bz2 dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar.lz dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar.xz dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.tar.zst dexon-b05f0240d48ba0c0c3f9cb1fec948b05733f2ba3.zip |
dex: implement notary node info propagation and management mechanism
Diffstat (limited to 'dex/helper_test.go')
-rw-r--r-- | dex/helper_test.go | 24 |
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 } |