Skip to content

Commit 5180524

Browse files
C0rWinGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "FAB-15046 Fix flaky Raft UT" into release-1.4
2 parents 472034f + b7ec307 commit 5180524

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

orderer/consensus/etcdraft/chain_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,32 +3622,31 @@ type network struct {
36223622
leader uint64
36233623
chains map[uint64]*chain
36243624

3625-
// links simulates the configuration of comm layer. if links[left][right] == true,
3626-
// the link between left and right is open on *left* side. A link must be open on
3627-
// both sides to allow message pass through.
3625+
// links simulates the configuration of comm layer (link is bi-directional).
3626+
// if links[left][right] == true, right can send msg to left.
36283627
links map[uint64]map[uint64]bool
36293628
// connectivity determines if a node is connected to network. This is used for tests
36303629
// to simulate network partition.
36313630
connectivity map[uint64]bool
36323631
}
36333632

3634-
func (n *network) link(from uint64, to []uint64) {
3633+
func (n *network) link(from []uint64, to uint64) {
36353634
links := make(map[uint64]bool)
3636-
for _, id := range to {
3635+
for _, id := range from {
36373636
links[id] = true
36383637
}
36393638

36403639
n.Lock()
36413640
defer n.Unlock()
36423641

3643-
n.links[from] = links
3642+
n.links[to] = links
36443643
}
36453644

36463645
func (n *network) linked(from, to uint64) bool {
36473646
n.RLock()
36483647
defer n.RUnlock()
36493648

3650-
return n.links[from][to] && n.links[to][from]
3649+
return n.links[to][from]
36513650
}
36523651

36533652
func (n *network) connect(id uint64) {
@@ -3748,7 +3747,7 @@ func (n *network) addChain(c *chain) {
37483747
for _, node := range nodes {
37493748
ids = append(ids, node.ID)
37503749
}
3751-
n.link(c.id, ids)
3750+
n.link(ids, c.id)
37523751
})
37533752

37543753
n.Lock()

0 commit comments

Comments
 (0)