diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-02-27 10:41:01 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:57 +0800 |
commit | e83bcc1097d49b46b79131e546f1270b9192cc05 (patch) | |
tree | a1af659afd80e3744177637cc06b2f0662a0ced8 /dex/peer_test.go | |
parent | 22b38ce74c3da40b7b7f24ada0abdf8d5ba03c64 (diff) | |
download | dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.gz dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.bz2 dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.lz dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.xz dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.zst dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.zip |
core: sync to latest core (#214)
* vendor: sync to latest core
* fix for single chain
Diffstat (limited to 'dex/peer_test.go')
-rw-r--r-- | dex/peer_test.go | 97 |
1 files changed, 18 insertions, 79 deletions
diff --git a/dex/peer_test.go b/dex/peer_test.go index 29b4971c5..76a28b1ef 100644 --- a/dex/peer_test.go +++ b/dex/peer_test.go @@ -19,41 +19,25 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { self := server.Self() table := newNodeTable() - gov := &testGovernance{ - numChainsFunc: func(uint64) uint32 { - return 3 - }, - } + gov := &testGovernance{} var nodes []*enode.Node for i := 0; i < 9; i++ { nodes = append(nodes, randomV4CompactNode()) } - round10 := [][]*enode.Node{ - {self, nodes[1], nodes[2]}, - {nodes[1], nodes[3]}, - {nodes[2], nodes[4]}, - } - round11 := [][]*enode.Node{ - {self, nodes[1], nodes[5]}, - {nodes[5], nodes[6]}, - {self, nodes[2], nodes[4]}, - } - round12 := [][]*enode.Node{ - {self, nodes[3], nodes[5]}, - {self, nodes[7], nodes[8]}, - {self, nodes[2], nodes[6]}, - } + round10 := []*enode.Node{self, nodes[1], nodes[2]} + round11 := []*enode.Node{self, nodes[1], nodes[5]} + round12 := []*enode.Node{self, nodes[3], nodes[5]} gov.notarySetFunc = func( - round uint64, cid uint32) (map[string]struct{}, error) { - m := map[uint64][][]*enode.Node{ + round uint64) (map[string]struct{}, error) { + m := map[uint64][]*enode.Node{ 10: round10, 11: round11, 12: round12, } - return newTestNodeSet(m[round][cid]), nil + return newTestNodeSet(m[round]), nil } gov.dkgSetFunc = func(round uint64) (map[string]struct{}, error) { @@ -73,58 +57,31 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { ps.BuildConnection(12) expectedlabel2Nodes := map[peerLabel]map[string]*enode.Node{ - {set: notaryset, round: 10, chainID: 0}: { + {set: notaryset, round: 10}: { self.ID().String(): self, nodes[1].ID().String(): nodes[1], nodes[2].ID().String(): nodes[2], }, - {set: notaryset, round: 10, chainID: 1}: { - nodes[1].ID().String(): nodes[1], - nodes[3].ID().String(): nodes[3], - }, - {set: notaryset, round: 10, chainID: 2}: { - nodes[2].ID().String(): nodes[2], - nodes[4].ID().String(): nodes[4], - }, {set: dkgset, round: 10}: { self.ID().String(): self, nodes[1].ID().String(): nodes[1], nodes[3].ID().String(): nodes[3], }, - {set: notaryset, round: 11, chainID: 0}: { + {set: notaryset, round: 11}: { self.ID().String(): self, nodes[1].ID().String(): nodes[1], nodes[5].ID().String(): nodes[5], }, - {set: notaryset, round: 11, chainID: 1}: { - nodes[5].ID().String(): nodes[5], - nodes[6].ID().String(): nodes[6], - }, - {set: notaryset, round: 11, chainID: 2}: { - self.ID().String(): self, - nodes[2].ID().String(): nodes[2], - nodes[4].ID().String(): nodes[4], - }, {set: dkgset, round: 11}: { nodes[1].ID().String(): nodes[1], nodes[2].ID().String(): nodes[2], nodes[5].ID().String(): nodes[5], }, - {set: notaryset, round: 12, chainID: 0}: { + {set: notaryset, round: 12}: { self.ID().String(): self, nodes[3].ID().String(): nodes[3], nodes[5].ID().String(): nodes[5], }, - {set: notaryset, round: 12, chainID: 1}: { - self.ID().String(): self, - nodes[7].ID().String(): nodes[7], - nodes[8].ID().String(): nodes[8], - }, - {set: notaryset, round: 12, chainID: 2}: { - self.ID().String(): self, - nodes[2].ID().String(): nodes[2], - nodes[6].ID().String(): nodes[6], - }, {set: dkgset, round: 12}: { self.ID().String(): self, nodes[3].ID().String(): nodes[3], @@ -137,14 +94,11 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { } expectedDirectConn := map[peerLabel]struct{}{ - {set: notaryset, round: 10, chainID: 0}: {}, - {set: notaryset, round: 11, chainID: 0}: {}, - {set: notaryset, round: 11, chainID: 2}: {}, - {set: notaryset, round: 12, chainID: 0}: {}, - {set: notaryset, round: 12, chainID: 1}: {}, - {set: notaryset, round: 12, chainID: 2}: {}, - {set: dkgset, round: 10}: {}, - {set: dkgset, round: 12}: {}, + {set: notaryset, round: 10}: {}, + {set: notaryset, round: 11}: {}, + {set: notaryset, round: 12}: {}, + {set: dkgset, round: 10}: {}, + {set: dkgset, round: 12}: {}, } if !reflect.DeepEqual(ps.directConn, expectedDirectConn) { @@ -152,9 +106,6 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { } expectedGroupConn := []peerLabel{ - {set: notaryset, round: 10, chainID: 1}, - {set: notaryset, round: 10, chainID: 2}, - {set: notaryset, round: 11, chainID: 1}, {set: dkgset, round: 11}, } @@ -196,21 +147,11 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { ps.ForgetConnection(11) expectedlabel2Nodes = map[peerLabel]map[string]*enode.Node{ - {set: notaryset, round: 12, chainID: 0}: { + {set: notaryset, round: 12}: { self.ID().String(): self, nodes[3].ID().String(): nodes[3], nodes[5].ID().String(): nodes[5], }, - {set: notaryset, round: 12, chainID: 1}: { - self.ID().String(): self, - nodes[7].ID().String(): nodes[7], - nodes[8].ID().String(): nodes[8], - }, - {set: notaryset, round: 12, chainID: 2}: { - self.ID().String(): self, - nodes[2].ID().String(): nodes[2], - nodes[6].ID().String(): nodes[6], - }, {set: dkgset, round: 12}: { self.ID().String(): self, nodes[3].ID().String(): nodes[3], @@ -223,10 +164,8 @@ func TestPeerSetBuildAndForgetConn(t *testing.T) { } expectedDirectConn = map[peerLabel]struct{}{ - {set: notaryset, round: 12, chainID: 0}: {}, - {set: notaryset, round: 12, chainID: 1}: {}, - {set: notaryset, round: 12, chainID: 2}: {}, - {set: dkgset, round: 12}: {}, + {set: notaryset, round: 12}: {}, + {set: dkgset, round: 12}: {}, } if !reflect.DeepEqual(ps.directConn, expectedDirectConn) { |