btctesting

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package btctesting defines helpers to test Bitcoin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	// The mock for the FindUnspent function.
	MockFindUnspent MockFindUnspent

	// The mock for the Broadcast function.
	MockBroadcast MockBroadcast
}

Mock is used to mock a UnspentFinder and Broadcaster.

It implements github.com/stratumn/go-core/fossilizer.Adapter.

func (*Mock) Broadcast

func (a *Mock) Broadcast(ctx context.Context, raw []byte) error

Broadcast implements github.com/stratumn/go-core/blockchain/btc.Broadcaster.Broadcast.

func (*Mock) FindUnspent

func (a *Mock) FindUnspent(ctx context.Context, address *types.ReversedBytes20, amount int64) (btc.UnspentResult, error)

FindUnspent implements github.com/stratumn/go-core/blockchain/btc.UnspentFinder.FindUnspent.

type MockBroadcast

type MockBroadcast struct {
	// The number of times the function was called.
	CalledCount int

	// The transaction that was passed to each call.
	CalledWith [][]byte

	// The last transaction that was passed.
	LastCalledWith []byte

	// An optional implementation of the function.
	Fn func(context.Context, []byte) error
}

MockBroadcast mocks the Broadcast function.

type MockFindUnspent

type MockFindUnspent struct {
	// The number of times the function was called.
	CalledCount int

	// The address that was passed to each call.
	CalledWithAddress []*types.ReversedBytes20

	// The amount that was passed to each call.
	CalledWithAmount []int64

	// The last address that was passed.
	LastCalledWithAddress *types.ReversedBytes20

	// The last amount that was passed.
	LastCalledWithAmount int64

	// An optional implementation of the function.
	Fn func(context.Context, *types.ReversedBytes20, int64) (btc.UnspentResult, error)
}

MockFindUnspent mocks the FindUnspent function.

Jump to

Keyboard shortcuts

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