Skip to content

Commit cdb794d

Browse files
authored
Merge branch 'main' into random-network
2 parents 146008a + 2b8c13a commit cdb794d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

testutil/comm.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ func (c *TestComm) Send(msg *simplex.Message, destination simplex.NodeID) {
6262

6363
// cannot send if either [from] or [destination] is not connected
6464
if c.net.IsDisconnected(destination) || c.net.IsDisconnected(c.from) {
65-
6665
for _, instance := range c.net.GetInstances() {
6766
if bytes.Equal(instance.E.ID, destination) {
68-
instance.l.Info("Node is disconnect not sending message")
67+
instance.l.Info("Node is disconnected not sending message")
6968
}
7069
}
7170

@@ -76,7 +75,7 @@ func (c *TestComm) Send(msg *simplex.Message, destination simplex.NodeID) {
7675

7776
for _, instance := range c.net.GetInstances() {
7877
if bytes.Equal(instance.E.ID, c.from) {
79-
instance.l.Info("Enqueing message")
78+
instance.l.Info("Enqueuing message")
8079
continue
8180
}
8281
if bytes.Equal(instance.E.ID, destination) {

testutil/network.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ func (b *BasicInMemoryNetwork) GetInstances() []*BasicNode {
119119
b.lock.RLock()
120120
defer b.lock.RUnlock()
121121

122-
return b.instances
122+
nodes := make([]*BasicNode, len(b.instances))
123+
copy(nodes, b.instances)
124+
return nodes
123125
}
124126

125127
func (b *BasicInMemoryNetwork) ReplaceNode(node *BasicNode) {

0 commit comments

Comments
 (0)