Skip to content

Commit e0f46d7

Browse files
authored
chore: update tests for ouroboros_mock 0.2.0 (#563)
Signed-off-by: Ales Verbic <[email protected]>
1 parent 43561a1 commit e0f46d7

File tree

4 files changed

+30
-40
lines changed

4 files changed

+30
-40
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21
55
toolchain go1.21.5
66

77
require (
8-
github.com/blinklabs-io/ouroboros-mock v0.1.0
8+
github.com/blinklabs-io/ouroboros-mock v0.2.0
99
github.com/fxamacker/cbor/v2 v2.6.0
1010
github.com/jinzhu/copier v0.4.0
1111
github.com/utxorpc/go-codegen v0.4.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/blinklabs-io/ouroboros-mock v0.1.0 h1:CvRnJAUMzzZVaY4CoqDedbRXyNXtZpzIkxK9KXNjdVI=
2-
github.com/blinklabs-io/ouroboros-mock v0.1.0/go.mod h1:t9eIDjmj339GJtfV7jandJnCqmj8WkZsFg2N1TR68io=
1+
github.com/blinklabs-io/ouroboros-mock v0.2.0 h1:Wff7mJiFUzktQ5tuWRN9vXNk38wR0ij2Q4bYHwJXaV4=
2+
github.com/blinklabs-io/ouroboros-mock v0.2.0/go.mod h1:t9eIDjmj339GJtfV7jandJnCqmj8WkZsFg2N1TR68io=
33
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1tWA=

protocol/handshake/client_test.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
ouroboros "github.com/blinklabs-io/gouroboros"
2424
"github.com/blinklabs-io/gouroboros/protocol"
2525
"github.com/blinklabs-io/gouroboros/protocol/handshake"
26-
"github.com/blinklabs-io/ouroboros-mock"
26+
ouroboros_mock "github.com/blinklabs-io/ouroboros-mock"
2727
"go.uber.org/goleak"
2828
)
2929

@@ -33,35 +33,32 @@ const (
3333
mockProtocolVersionNtNV11 uint16 = 11
3434
)
3535

36-
var conversationEntryNtCResponse = ouroboros_mock.ConversationEntry{
37-
Type: ouroboros_mock.EntryTypeOutput,
36+
var conversationEntryNtCResponse = ouroboros_mock.ConversationEntryOutput{
3837
ProtocolId: handshake.ProtocolId,
3938
IsResponse: true,
40-
OutputMessages: []protocol.Message{
39+
Messages: []protocol.Message{
4140
handshake.NewMsgAcceptVersion(
4241
mockProtocolVersionNtC,
4342
mockNtCVersionData(),
4443
),
4544
},
4645
}
4746

48-
var conversationEntryNtNResponse = ouroboros_mock.ConversationEntry{
49-
Type: ouroboros_mock.EntryTypeOutput,
47+
var conversationEntryNtNResponse = ouroboros_mock.ConversationEntryOutput{
5048
ProtocolId: handshake.ProtocolId,
5149
IsResponse: true,
52-
OutputMessages: []protocol.Message{
50+
Messages: []protocol.Message{
5351
handshake.NewMsgAcceptVersion(
5452
mockProtocolVersionNtN,
5553
mockNtNVersionData(),
5654
),
5755
},
5856
}
5957

60-
var conversationEntryNtNResponseV11 = ouroboros_mock.ConversationEntry{
61-
Type: ouroboros_mock.EntryTypeOutput,
58+
var conversationEntryNtNResponseV11 = ouroboros_mock.ConversationEntryOutput{
6259
ProtocolId: handshake.ProtocolId,
6360
IsResponse: true,
64-
OutputMessages: []protocol.Message{
61+
Messages: []protocol.Message{
6562
handshake.NewMsgAcceptVersion(
6663
mockProtocolVersionNtNV11,
6764
mockNtNVersionDataV11(),
@@ -232,11 +229,10 @@ func TestClientNtCRefuseVersionMismatch(t *testing.T) {
232229
ouroboros_mock.ProtocolRoleClient,
233230
[]ouroboros_mock.ConversationEntry{
234231
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
235-
ouroboros_mock.ConversationEntry{
236-
Type: ouroboros_mock.EntryTypeOutput,
232+
ouroboros_mock.ConversationEntryOutput{
237233
ProtocolId: handshake.ProtocolId,
238234
IsResponse: true,
239-
OutputMessages: []protocol.Message{
235+
Messages: []protocol.Message{
240236
handshake.NewMsgRefuse(
241237
[]any{
242238
handshake.RefuseReasonVersionMismatch,
@@ -267,11 +263,10 @@ func TestClientNtCRefuseDecodeError(t *testing.T) {
267263
ouroboros_mock.ProtocolRoleClient,
268264
[]ouroboros_mock.ConversationEntry{
269265
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
270-
ouroboros_mock.ConversationEntry{
271-
Type: ouroboros_mock.EntryTypeOutput,
266+
ouroboros_mock.ConversationEntryOutput{
272267
ProtocolId: handshake.ProtocolId,
273268
IsResponse: true,
274-
OutputMessages: []protocol.Message{
269+
Messages: []protocol.Message{
275270
handshake.NewMsgRefuse(
276271
[]any{
277272
handshake.RefuseReasonDecodeError,
@@ -303,11 +298,10 @@ func TestClientNtCRefuseRefused(t *testing.T) {
303298
ouroboros_mock.ProtocolRoleClient,
304299
[]ouroboros_mock.ConversationEntry{
305300
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
306-
ouroboros_mock.ConversationEntry{
307-
Type: ouroboros_mock.EntryTypeOutput,
301+
ouroboros_mock.ConversationEntryOutput{
308302
ProtocolId: handshake.ProtocolId,
309303
IsResponse: true,
310-
OutputMessages: []protocol.Message{
304+
Messages: []protocol.Message{
311305
handshake.NewMsgRefuse(
312306
[]any{
313307
handshake.RefuseReasonRefused,

protocol/handshake/server_test.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"time"
2121

2222
ouroboros "github.com/blinklabs-io/gouroboros"
23-
"github.com/blinklabs-io/ouroboros-mock"
2423
"github.com/blinklabs-io/gouroboros/protocol"
2524
"github.com/blinklabs-io/gouroboros/protocol/handshake"
25+
ouroboros_mock "github.com/blinklabs-io/ouroboros-mock"
2626
"go.uber.org/goleak"
2727
)
2828

@@ -32,10 +32,9 @@ func TestServerBasicHandshake(t *testing.T) {
3232
ouroboros_mock.ProtocolRoleServer,
3333
[]ouroboros_mock.ConversationEntry{
3434
// MsgProposeVersions from mock client
35-
{
36-
Type: ouroboros_mock.EntryTypeOutput,
35+
ouroboros_mock.ConversationEntryOutput{
3736
ProtocolId: handshake.ProtocolId,
38-
OutputMessages: []protocol.Message{
37+
Messages: []protocol.Message{
3938
handshake.NewMsgProposeVersions(
4039
protocol.ProtocolVersionMap{
4140
(10 + protocol.ProtocolVersionNtCOffset): protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
@@ -46,12 +45,11 @@ func TestServerBasicHandshake(t *testing.T) {
4645
},
4746
},
4847
// MsgAcceptVersion from server
49-
{
50-
Type: ouroboros_mock.EntryTypeInput,
51-
IsResponse: true,
48+
ouroboros_mock.ConversationEntryInput{
5249
ProtocolId: handshake.ProtocolId,
50+
IsResponse: true,
5351
MsgFromCborFunc: handshake.NewMsgFromCbor,
54-
InputMessage: handshake.NewMsgAcceptVersion(
52+
Message: handshake.NewMsgAcceptVersion(
5553
(12 + protocol.ProtocolVersionNtCOffset),
5654
protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
5755
),
@@ -96,10 +94,9 @@ func TestServerHandshakeRefuseVersionMismatch(t *testing.T) {
9694
ouroboros_mock.ProtocolRoleServer,
9795
[]ouroboros_mock.ConversationEntry{
9896
// MsgProposeVersions from mock client
99-
{
100-
Type: ouroboros_mock.EntryTypeOutput,
97+
ouroboros_mock.ConversationEntryOutput{
10198
ProtocolId: handshake.ProtocolId,
102-
OutputMessages: []protocol.Message{
99+
Messages: []protocol.Message{
103100
handshake.NewMsgProposeVersions(
104101
protocol.ProtocolVersionMap{
105102
(100 + protocol.ProtocolVersionNtCOffset): protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
@@ -110,13 +107,12 @@ func TestServerHandshakeRefuseVersionMismatch(t *testing.T) {
110107
},
111108
},
112109
// MsgRefuse from server
113-
{
114-
Type: ouroboros_mock.EntryTypeInput,
115-
IsResponse: true,
116-
ProtocolId: handshake.ProtocolId,
117-
MsgFromCborFunc: handshake.NewMsgFromCbor,
118-
InputMessageType: handshake.MessageTypeRefuse,
119-
InputMessage: handshake.NewMsgRefuse(
110+
ouroboros_mock.ConversationEntryInput{
111+
IsResponse: true,
112+
ProtocolId: handshake.ProtocolId,
113+
MsgFromCborFunc: handshake.NewMsgFromCbor,
114+
MessageType: handshake.MessageTypeRefuse,
115+
Message: handshake.NewMsgRefuse(
120116
[]any{
121117
handshake.RefuseReasonVersionMismatch,
122118
// Convert []uint16 to []any

0 commit comments

Comments
 (0)