From d9c714d5bde36f11c0c18827d5299a5d64bb5b51 Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Sun, 24 Mar 2024 15:32:48 -0400 Subject: [PATCH] chore: update tests for ouroboros_mock 0.2.0 Signed-off-by: Ales Verbic --- go.mod | 2 +- go.sum | 4 ++-- protocol/handshake/client_test.go | 32 +++++++++++++------------------ protocol/handshake/server_test.go | 32 ++++++++++++++----------------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/go.mod b/go.mod index 098e4f9d..7e66bc41 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index d8102dcf..90c92bbe 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/protocol/handshake/client_test.go b/protocol/handshake/client_test.go index f9c08e91..3c9dc607 100644 --- a/protocol/handshake/client_test.go +++ b/protocol/handshake/client_test.go @@ -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" ) @@ -33,11 +33,10 @@ 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(), @@ -45,11 +44,10 @@ var conversationEntryNtCResponse = ouroboros_mock.ConversationEntry{ }, } -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(), @@ -57,11 +55,10 @@ var conversationEntryNtNResponse = ouroboros_mock.ConversationEntry{ }, } -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(), @@ -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, @@ -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, @@ -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, diff --git a/protocol/handshake/server_test.go b/protocol/handshake/server_test.go index 7834b8c0..8b4ac7aa 100644 --- a/protocol/handshake/server_test.go +++ b/protocol/handshake/server_test.go @@ -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" ) @@ -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), @@ -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), ), @@ -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), @@ -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