ouroboros_mock

package
v0.58.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockNetworkMagic       uint32 = 999999
	MockProtocolVersionNtC uint16 = 14
)

Variables

View Source
var ConversationEntryHandshakeRequestGeneric = ConversationEntry{
	Type:             EntryTypeInput,
	ProtocolId:       handshake.ProtocolId,
	InputMessageType: handshake.MessageTypeProposeVersions,
}

ConversationEntryHandshakeRequestGeneric is a pre-defined conversation event that matches a generic handshake request from a client

View Source
var ConversationEntryHandshakeResponse = ConversationEntry{
	Type:       EntryTypeOutput,
	ProtocolId: handshake.ProtocolId,
	IsResponse: true,
	OutputMessages: []protocol.Message{
		handshake.NewMsgAcceptVersion(MockProtocolVersionNtC, MockNetworkMagic),
	},
}

ConversationEntryHandshakeResponse is a pre-defined conversation entry for a server NtC handshake response

Functions

func NewConnection

func NewConnection(protocolRole ProtocolRole, conversation []ConversationEntry) net.Conn

NewConnection returns a new Connection with the provided conversation entries

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection mocks an Ouroboros connection

func (*Connection) Close

func (c *Connection) Close() error

Close closes both sides of the connection. This is needed to satisfy the net.Conn interface

func (*Connection) LocalAddr

func (c *Connection) LocalAddr() net.Addr

LocalAddr provides a proxy to the client-side connection's LocalAddr function. This is needed to satisfy the net.Conn interface

func (*Connection) Read

func (c *Connection) Read(b []byte) (n int, err error)

Read provides a proxy to the client-side connection's Read function. This is needed to satisfy the net.Conn interface

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

RemoteAddr provides a proxy to the client-side connection's RemoteAddr function. This is needed to satisfy the net.Conn interface

func (*Connection) SetDeadline

func (c *Connection) SetDeadline(t time.Time) error

SetDeadline provides a proxy to the client-side connection's SetDeadline function. This is needed to satisfy the net.Conn interface

func (*Connection) SetReadDeadline

func (c *Connection) SetReadDeadline(t time.Time) error

SetReadDeadline provides a proxy to the client-side connection's SetReadDeadline function. This is needed to satisfy the net.Conn interface

func (*Connection) SetWriteDeadline

func (c *Connection) SetWriteDeadline(t time.Time) error

SetWriteDeadline provides a proxy to the client-side connection's SetWriteDeadline function. This is needed to satisfy the net.Conn interface

func (*Connection) Write

func (c *Connection) Write(b []byte) (n int, err error)

Write provides a proxy to the client-side connection's Write function. This is needed to satisfy the net.Conn interface

type ConversationEntry

type ConversationEntry struct {
	Type             EntryType
	ProtocolId       uint16
	IsResponse       bool
	OutputMessages   []protocol.Message
	InputMessage     protocol.Message
	InputMessageType uint
	MsgFromCborFunc  protocol.MessageFromCborFunc
}

type EntryType

type EntryType int
const (
	EntryTypeNone   EntryType = 0
	EntryTypeInput  EntryType = 1
	EntryTypeOutput EntryType = 2
	EntryTypeClose  EntryType = 3
)

type ProtocolRole added in v0.42.0

type ProtocolRole uint

ProtocolRole is an enum of the protocol roles

const (
	ProtocolRoleNone   ProtocolRole = 0 // Default (invalid) protocol role
	ProtocolRoleClient ProtocolRole = 1 // Client protocol role
	ProtocolRoleServer ProtocolRole = 2 // Server protocol role
)

Protocol roles

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL