Skip to content

chore: update tests for ouroboros_mock 0.2.0 #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.5

require (
github.com/blinklabs-io/ouroboros-mock v0.1.0
github.com/blinklabs-io/ouroboros-mock v0.2.0
github.com/fxamacker/cbor/v2 v2.6.0
github.com/jinzhu/copier v0.4.0
github.com/utxorpc/go-codegen v0.4.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/blinklabs-io/ouroboros-mock v0.1.0 h1:CvRnJAUMzzZVaY4CoqDedbRXyNXtZpzIkxK9KXNjdVI=
github.com/blinklabs-io/ouroboros-mock v0.1.0/go.mod h1:t9eIDjmj339GJtfV7jandJnCqmj8WkZsFg2N1TR68io=
github.com/blinklabs-io/ouroboros-mock v0.2.0 h1:Wff7mJiFUzktQ5tuWRN9vXNk38wR0ij2Q4bYHwJXaV4=
github.com/blinklabs-io/ouroboros-mock v0.2.0/go.mod h1:t9eIDjmj339GJtfV7jandJnCqmj8WkZsFg2N1TR68io=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1tWA=
Expand Down
32 changes: 13 additions & 19 deletions protocol/handshake/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
ouroboros "github.com/blinklabs-io/gouroboros"
"github.com/blinklabs-io/gouroboros/protocol"
"github.com/blinklabs-io/gouroboros/protocol/handshake"
"github.com/blinklabs-io/ouroboros-mock"
ouroboros_mock "github.com/blinklabs-io/ouroboros-mock"
"go.uber.org/goleak"
)

Expand All @@ -33,35 +33,32 @@ const (
mockProtocolVersionNtNV11 uint16 = 11
)

var conversationEntryNtCResponse = ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
var conversationEntryNtCResponse = ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgAcceptVersion(
mockProtocolVersionNtC,
mockNtCVersionData(),
),
},
}

var conversationEntryNtNResponse = ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
var conversationEntryNtNResponse = ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgAcceptVersion(
mockProtocolVersionNtN,
mockNtNVersionData(),
),
},
}

var conversationEntryNtNResponseV11 = ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
var conversationEntryNtNResponseV11 = ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgAcceptVersion(
mockProtocolVersionNtNV11,
mockNtNVersionDataV11(),
Expand Down Expand Up @@ -232,11 +229,10 @@ func TestClientNtCRefuseVersionMismatch(t *testing.T) {
ouroboros_mock.ProtocolRoleClient,
[]ouroboros_mock.ConversationEntry{
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgRefuse(
[]any{
handshake.RefuseReasonVersionMismatch,
Expand Down Expand Up @@ -267,11 +263,10 @@ func TestClientNtCRefuseDecodeError(t *testing.T) {
ouroboros_mock.ProtocolRoleClient,
[]ouroboros_mock.ConversationEntry{
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgRefuse(
[]any{
handshake.RefuseReasonDecodeError,
Expand Down Expand Up @@ -303,11 +298,10 @@ func TestClientNtCRefuseRefused(t *testing.T) {
ouroboros_mock.ProtocolRoleClient,
[]ouroboros_mock.ConversationEntry{
ouroboros_mock.ConversationEntryHandshakeRequestGeneric,
ouroboros_mock.ConversationEntry{
Type: ouroboros_mock.EntryTypeOutput,
ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgRefuse(
[]any{
handshake.RefuseReasonRefused,
Expand Down
32 changes: 14 additions & 18 deletions protocol/handshake/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"time"

ouroboros "github.com/blinklabs-io/gouroboros"
"github.com/blinklabs-io/ouroboros-mock"
"github.com/blinklabs-io/gouroboros/protocol"
"github.com/blinklabs-io/gouroboros/protocol/handshake"
ouroboros_mock "github.com/blinklabs-io/ouroboros-mock"
"go.uber.org/goleak"
)

Expand All @@ -32,10 +32,9 @@ func TestServerBasicHandshake(t *testing.T) {
ouroboros_mock.ProtocolRoleServer,
[]ouroboros_mock.ConversationEntry{
// MsgProposeVersions from mock client
{
Type: ouroboros_mock.EntryTypeOutput,
ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgProposeVersions(
protocol.ProtocolVersionMap{
(10 + protocol.ProtocolVersionNtCOffset): protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
Expand All @@ -46,12 +45,11 @@ func TestServerBasicHandshake(t *testing.T) {
},
},
// MsgAcceptVersion from server
{
Type: ouroboros_mock.EntryTypeInput,
IsResponse: true,
ouroboros_mock.ConversationEntryInput{
ProtocolId: handshake.ProtocolId,
IsResponse: true,
MsgFromCborFunc: handshake.NewMsgFromCbor,
InputMessage: handshake.NewMsgAcceptVersion(
Message: handshake.NewMsgAcceptVersion(
(12 + protocol.ProtocolVersionNtCOffset),
protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
),
Expand Down Expand Up @@ -96,10 +94,9 @@ func TestServerHandshakeRefuseVersionMismatch(t *testing.T) {
ouroboros_mock.ProtocolRoleServer,
[]ouroboros_mock.ConversationEntry{
// MsgProposeVersions from mock client
{
Type: ouroboros_mock.EntryTypeOutput,
ouroboros_mock.ConversationEntryOutput{
ProtocolId: handshake.ProtocolId,
OutputMessages: []protocol.Message{
Messages: []protocol.Message{
handshake.NewMsgProposeVersions(
protocol.ProtocolVersionMap{
(100 + protocol.ProtocolVersionNtCOffset): protocol.VersionDataNtC9to14(ouroboros_mock.MockNetworkMagic),
Expand All @@ -110,13 +107,12 @@ func TestServerHandshakeRefuseVersionMismatch(t *testing.T) {
},
},
// MsgRefuse from server
{
Type: ouroboros_mock.EntryTypeInput,
IsResponse: true,
ProtocolId: handshake.ProtocolId,
MsgFromCborFunc: handshake.NewMsgFromCbor,
InputMessageType: handshake.MessageTypeRefuse,
InputMessage: handshake.NewMsgRefuse(
ouroboros_mock.ConversationEntryInput{
IsResponse: true,
ProtocolId: handshake.ProtocolId,
MsgFromCborFunc: handshake.NewMsgFromCbor,
MessageType: handshake.MessageTypeRefuse,
Message: handshake.NewMsgRefuse(
[]any{
handshake.RefuseReasonVersionMismatch,
// Convert []uint16 to []any
Expand Down