diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-11-06 14:32:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-06 14:32:48 +0800 |
commit | e662353293b58637acc788a5c214a8904bb1cfcb (patch) | |
tree | 46d56a0c25dd5b96227ddbbc16892bee023bc360 /core/test | |
parent | c537e964d9031a07c125a7225391e26827d9eb7a (diff) | |
download | dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar.gz dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar.bz2 dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar.lz dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar.xz dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.tar.zst dexon-consensus-e662353293b58637acc788a5c214a8904bb1cfcb.zip |
core: Run DKG stuffs only if the node is in DKG set (#302)
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/fake-transport.go | 21 | ||||
-rw-r--r-- | core/test/interface.go | 19 | ||||
-rw-r--r-- | core/test/tcp-transport.go | 6 | ||||
-rw-r--r-- | core/test/transport_test.go | 4 |
4 files changed, 42 insertions, 8 deletions
diff --git a/core/test/fake-transport.go b/core/test/fake-transport.go index 03acba5..a783ac9 100644 --- a/core/test/fake-transport.go +++ b/core/test/fake-transport.go @@ -1,6 +1,23 @@ // Copyright 2018 The dexon-consensus Authors // This file is part of the dexon-consensus library. // +// The dexon-consensus library is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The dexon-consensus library is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the dexon-consensus library. If not, see +// <http://www.gnu.org/licenses/>. + +// Copyright 2018 The dexon-consensus Authors +// This file is part of the dexon-consensus library. +// // The dexon-consensus library is free software: you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either version 3 of the License, @@ -161,7 +178,7 @@ func (t *FakeTransport) Host() (chan *TransportEnvelope, error) { } // WaitForPeers implements TransportServer.WaitForPeers method. -func (t *FakeTransport) WaitForPeers(numPeers int) (err error) { +func (t *FakeTransport) WaitForPeers(numPeers uint32) (err error) { t.peers = make(map[types.NodeID]fakePeerRecord) for { envelope := <-t.recvChannel @@ -172,7 +189,7 @@ func (t *FakeTransport) WaitForPeers(numPeers int) (err error) { sendChannel: newPeer.recvChannel, pubKey: newPeer.pubKey, } - if len(t.peers) == numPeers { + if uint32(len(t.peers)) == numPeers { break } } diff --git a/core/test/interface.go b/core/test/interface.go index 9ff79db..e7a8f70 100644 --- a/core/test/interface.go +++ b/core/test/interface.go @@ -8,6 +8,23 @@ // // The dexon-consensus library is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the dexon-consensus library. If not, see +// <http://www.gnu.org/licenses/>. + +// Copyright 2018 The dexon-consensus Authors +// This file is part of the dexon-consensus library. +// +// The dexon-consensus library is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The dexon-consensus library is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // @@ -76,7 +93,7 @@ type TransportServer interface { // returned channel could be used after 'WaitForPeers' returns. Host() (chan *TransportEnvelope, error) // WaitForPeers waits for all peers to join the network. - WaitForPeers(numPeers int) error + WaitForPeers(numPeers uint32) error } // TransportClient defines those peers in the network. diff --git a/core/test/tcp-transport.go b/core/test/tcp-transport.go index 285b630..a3b9aba 100644 --- a/core/test/tcp-transport.go +++ b/core/test/tcp-transport.go @@ -743,7 +743,7 @@ func (t *TCPTransportServer) Host() (chan *TransportEnvelope, error) { } // WaitForPeers implements TransportServer.WaitForPeers method. -func (t *TCPTransportServer) WaitForPeers(numPeers int) (err error) { +func (t *TCPTransportServer) WaitForPeers(numPeers uint32) (err error) { // Collect peers info. Packets other than peer info is // unexpected. peersInfo := make(map[types.NodeID]string) @@ -764,7 +764,7 @@ func (t *TCPTransportServer) WaitForPeers(numPeers int) (err error) { } peersInfo[msg.NodeID] = msg.Info // Check if we already collect enought peers. - if len(peersInfo) == numPeers { + if uint32(len(peersInfo)) == numPeers { break } } @@ -790,7 +790,7 @@ func (t *TCPTransportServer) WaitForPeers(numPeers int) (err error) { panic(fmt.Errorf("already report conn-ready message: %v", e)) } readies[msg.NodeID] = struct{}{} - if len(readies) == numPeers { + if uint32(len(readies)) == numPeers { break } } diff --git a/core/test/transport_test.go b/core/test/transport_test.go index d5032cd..d5c4260 100644 --- a/core/test/transport_test.go +++ b/core/test/transport_test.go @@ -223,7 +223,7 @@ func (s *TransportTestSuite) TestFake() { }() } // Block here until we collect enough peers. - server.trans.WaitForPeers(peerCount) + server.trans.WaitForPeers(uint32(peerCount)) // Make sure all clients are ready. wg.Wait() s.baseTest(server, peers, 300*time.Millisecond) @@ -270,7 +270,7 @@ func (s *TransportTestSuite) TestTCPLocal() { }() } // Block here until we collect enough peers. - server.trans.WaitForPeers(peerCount) + server.trans.WaitForPeers(uint32(peerCount)) // Make sure all clients are ready. wg.Wait() |