Skip to content

Commit

Permalink
Merge "FAB-15046 Fix flaky Raft UT" into release-1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rWin authored and Gerrit Code Review committed Apr 11, 2019
2 parents 472034f + b7ec307 commit 5180524
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions orderer/consensus/etcdraft/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3622,32 +3622,31 @@ type network struct {
leader uint64
chains map[uint64]*chain

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

func (n *network) link(from uint64, to []uint64) {
func (n *network) link(from []uint64, to uint64) {
links := make(map[uint64]bool)
for _, id := range to {
for _, id := range from {
links[id] = true
}

n.Lock()
defer n.Unlock()

n.links[from] = links
n.links[to] = links
}

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

return n.links[from][to] && n.links[to][from]
return n.links[to][from]
}

func (n *network) connect(id uint64) {
Expand Down Expand Up @@ -3748,7 +3747,7 @@ func (n *network) addChain(c *chain) {
for _, node := range nodes {
ids = append(ids, node.ID)
}
n.link(c.id, ids)
n.link(ids, c.id)
})

n.Lock()
Expand Down

0 comments on commit 5180524

Please sign in to comment.