wtmock

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockPeer

type MockPeer struct {
	IncomingMsgs chan []byte
	OutgoingMsgs chan []byte

	Quit chan struct{}
	// contains filtered or unexported fields
}

MockPeer emulates a single endpoint of brontide transport.

func NewMockPeer

func NewMockPeer(pk *btcec.PublicKey, addr net.Addr, bufferSize int) *MockPeer

NewMockPeer returns a fresh MockPeer.

func (*MockPeer) Close

func (p *MockPeer) Close() error

Close tearsdown the connection, and fails any pending reads or writes.

func (*MockPeer) ReadNextMessage

func (p *MockPeer) ReadNextMessage() ([]byte, error)

ReadNextMessage returns the raw bytes of the next full message read from the remote peer. The read will fail if either party closes the connection or the read deadline expires.

func (*MockPeer) RemoteAddr

func (p *MockPeer) RemoteAddr() net.Addr

RemoteAddr returns the net address of the remote peer.

func (*MockPeer) RemotePub

func (p *MockPeer) RemotePub() *btcec.PublicKey

RemotePub returns the public key of the remote peer.

func (*MockPeer) SetReadDeadline

func (p *MockPeer) SetReadDeadline(t time.Time) error

SetReadDeadline initializes a timer that will cause any pending reads to fail at time t. If t is zero, the deadline is infinite.

func (*MockPeer) SetWriteDeadline

func (p *MockPeer) SetWriteDeadline(t time.Time) error

SetWriteDeadline initializes a timer that will cause any pending writes to fail at time t. If t is zero, the deadline is infinite.

func (*MockPeer) Write

func (p *MockPeer) Write(b []byte) (n int, err error)

Write sends the raw bytes as the next full message read to the remote peer. The write will fail if either party closes the connection or the write deadline expires. The passed bytes slice is copied before sending, thus the bytes may be reused once the method returns.

type MockSigner

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

MockSigner is an input.Signer that allows one to add arbitrary private keys and sign messages by passing the assigned keychain.KeyLocator.

func NewMockSigner

func NewMockSigner() *MockSigner

NewMockSigner returns a fresh MockSigner.

func (*MockSigner) AddPrivKey

func (s *MockSigner) AddPrivKey(privKey *btcec.PrivateKey) keychain.KeyLocator

AddPrivKey records the passed privKey in the MockSigner's registry of keys it can sign with in the future. A unique key locator is returned, allowing the caller to sign with this key when presented via an input.SignDescriptor.

func (*MockSigner) ComputeInputScript

func (s *MockSigner) ComputeInputScript(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (*input.Script, error)

ComputeInputScript is not implemented.

func (*MockSigner) SignOutputRaw

func (s *MockSigner) SignOutputRaw(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) ([]byte, error)

SignOutputRaw signs an input on the passed transaction using the input index in the sign descriptor. The returned signature is the raw DER-encoded signature without the signhash flag.

Jump to

Keyboard shortcuts

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