-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
60 lines (41 loc) · 1.03 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"gossip-gloomers/testutils"
"testing"
"github.com/gkampitakis/go-snaps/snaps"
maelstrom "github.com/jepsen-io/maelstrom/demo/go"
"github.com/stretchr/testify/require"
)
func Test(t *testing.T) {
require := require.New(t)
node = maelstrom.NewNode()
link := testutils.NewLink(node)
client := testutils.NewClient("c0", link)
go main()
err := client.InitNode("n0", []string{"n0"})
require.NoError(err)
topologyOutput, err := client.RPC(TopologyRequest{
MessageBody: maelstrom.MessageBody{
Type: "topology",
MsgID: 2,
},
Topology: map[string][]string{"n0": {}},
})
require.NoError(err)
snaps.MatchSnapshot(t, topologyOutput)
broadcastOutput, err := client.RPC(BroadcastRequest{
MessageBody: maelstrom.MessageBody{
Type: "broadcast",
MsgID: 2,
},
Message: 1,
})
require.NoError(err)
snaps.MatchSnapshot(t, broadcastOutput)
readOutput, err := client.RPC(maelstrom.MessageBody{
Type: "read",
MsgID: 2,
})
require.NoError(err)
snaps.MatchSnapshot(t, readOutput)
}