Skip to content

Commit

Permalink
Merge pull request #211 from symbiont-io/fix-broadcast
Browse files Browse the repository at this point in the history
bug(sut/broadcast): partial revert of 5b27e7c
  • Loading branch information
symbiont-stevan-andjelkovic authored Apr 9, 2021
2 parents 84779ae + 753f33a commit b95df43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
21 changes: 4 additions & 17 deletions src/sut/broadcast/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ type Node struct {

// The round or version of the implementation.
Round Round `json:"round"`

// Node name.
Name string `json:"name"`
}

type Broadcast struct {
Expand All @@ -80,11 +77,10 @@ func NewNodeA(round Round) *Node {
"C": true,
},
Round: round,
Name: "A",
}
}

func NewNode(name string, round Round) *Node {
func NewNode(round Round, neighbour string) *Node {
var broadcast bool
switch round {
case SimpleDeliv, RetryDeliv, ClassicDeliv:
Expand All @@ -94,30 +90,21 @@ func NewNode(name string, round Round) *Node {
default:
panic("Unknown round")
}
neighbours := make(map[string]bool, 3)
var neighbour string
switch name {
case "B":
neighbour = "C"
case "C":
neighbour = "B"
default:
panic("unexpected name")
}
neighbours := make(map[string]bool)
neighbours[neighbour] = broadcast

if round == ClassicDeliv && name == "B" || name == "C" {
if round == ClassicDeliv {
// Normally node A isn't considered a neighbour, but in the
// classic delivery example it seems like node B and C should
// send messages back to A.
neighbours["A"] = broadcast
neighbours[neighbour] = broadcast
}

return &Node{
Log: "",
Neighbours: neighbours,
Round: round,
Name: name,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/sut/broadcast/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
func once(round Round, testId lib.TestId, runEvent lib.CreateRunEvent, t *testing.T) (lib.RunId, bool) {
topology := lib.NewTopology(
lib.Item{"A", NewNodeA(round)},
lib.Item{"B", NewNode("B", round)},
lib.Item{"C", NewNode("C", round)},
lib.Item{"B", NewNode(round, "C")},
lib.Item{"C", NewNode(round, "B")},
)
marshaler := NewMarshaler()
var srv http.Server
Expand Down Expand Up @@ -53,7 +53,7 @@ func many(round Round, expectedRuns int, t *testing.T, expectedFaults []lib.Faul
// time, we can't. And we also got timers which increase the
// logical clock, which means we sometimes need a higher EFF in
// order to find the problem.
EFF: 5,
EFF: 3,
Crashes: 1,
EOT: 10,
}
Expand Down

0 comments on commit b95df43

Please sign in to comment.