test

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Overview

Package test contains testing setup types and functions for package client.

Package test contains helpers for testing the client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysAcceptChannelHandler added in v0.10.0

func AlwaysAcceptChannelHandler(ctx context.Context, addr wallet.Address, channels chan *client.Channel, errs chan<- error) client.ProposalHandlerFunc

AlwaysAcceptChannelHandler returns a channel proposal handler that accepts all channel proposals.

func AlwaysAcceptUpdateHandler added in v0.10.0

func AlwaysAcceptUpdateHandler(ctx context.Context, errs chan error) client.UpdateHandlerFunc

AlwaysAcceptUpdateHandler returns a channel update handler that accepts all channel updates.

func AlwaysRejectChannelHandler added in v0.10.0

func AlwaysRejectChannelHandler(ctx context.Context, errs chan<- error) client.ProposalHandlerFunc

AlwaysRejectChannelHandler returns a channel proposal handler that rejects all channel proposals.

func AlwaysRejectUpdateHandler added in v0.10.1

func AlwaysRejectUpdateHandler(ctx context.Context, errs chan error) client.UpdateHandlerFunc

AlwaysRejectUpdateHandler returns a channel update handler that rejects all channel updates.

func ChannelSyncMsgSerializationTest added in v0.9.0

func ChannelSyncMsgSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))

ChannelSyncMsgSerializationTest runs serialization tests on channel sync messages.

func EqualBalancesWithDelta added in v0.10.2

func EqualBalancesWithDelta(
	bals1 channel.Balances,
	bals2 channel.Balances,
	delta channel.Bal,
) bool

EqualBalancesWithDelta checks whether the given balances are equal up to delta.

func ExecuteTwoPartyTest added in v0.6.0

func ExecuteTwoPartyTest(ctx context.Context, t *testing.T, role [2]Executer, cfg ExecConfig)

ExecuteTwoPartyTest executes the specified client test.

func NewRandomLedgerChannelProposal added in v0.5.0

func NewRandomLedgerChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) *client.LedgerChannelProposalMsg

NewRandomLedgerChannelProposal creates a random channel proposal with the supplied options. Number of participants is fixed to randomProposalNumParts.

func NewRandomLedgerChannelProposalBy added in v0.5.0

func NewRandomLedgerChannelProposalBy(rng *rand.Rand, proposer wallet.Address, opts ...client.ProposalOpts) *client.LedgerChannelProposalMsg

NewRandomLedgerChannelProposalBy creates a random channel proposal with the supplied options and proposer. Number of participants is fixed to randomProposalNumParts.

func NewRandomSubChannelProposal added in v0.5.0

func NewRandomSubChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) (*client.SubChannelProposalMsg, error)

NewRandomSubChannelProposal creates a random subchannel proposal with the supplied options. Number of participants is fixed to 2.

func NewRandomVirtualChannelProposal added in v0.7.0

func NewRandomVirtualChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) (*client.VirtualChannelProposalMsg, error)

NewRandomVirtualChannelProposal creates a random virtual channel proposal with the supplied options. Number of participants is fixed to 2.

func ProposalMsgsSerializationTest added in v0.9.0

func ProposalMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))

ProposalMsgsSerializationTest runs serialization tests on proposal messages.

func TestFundRecovery added in v0.10.4

func TestFundRecovery(
	ctx context.Context,
	t *testing.T,
	params FundSetup,
	setup func(*rand.Rand) ([2]RoleSetup, channel.Asset),
)

TestFundRecovery performs a test of the fund recovery functionality for the given setup.

func TestMultiLedgerDispute added in v0.10.2

func TestMultiLedgerDispute(
	ctx context.Context,
	t *testing.T,
	mlt MultiLedgerSetup,
	challengeDuration uint64,
)

TestMultiLedgerDispute runs an end-to-end test of the multi-ledger functionality in the dispute case for the implementation specified in the test setup.

func TestMultiLedgerHappy added in v0.10.2

func TestMultiLedgerHappy(ctx context.Context, t *testing.T, mlt MultiLedgerSetup, challengeDuration uint64)

TestMultiLedgerHappy runs an end-to-end test of the multi-ledger functionality in the optimistic case for the implementation specified in the test setup.

func TestVirtualChannelDispute added in v0.10.5

func TestVirtualChannelDispute(
	ctx context.Context,
	t *testing.T,
	setup VirtualChannelSetup,
)

TestVirtualChannelDispute tests virtual channel functionality in the dispute case.

func TestVirtualChannelOptimistic added in v0.10.5

func TestVirtualChannelOptimistic(
	ctx context.Context,
	t *testing.T,
	setup VirtualChannelSetup,
)

TestVirtualChannelOptimistic tests virtual channel functionality in the optimistic case.

func UpdateMsgsSerializationTest added in v0.9.0

func UpdateMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))

UpdateMsgsSerializationTest runs serialization tests on update messages.

Types

type Alice

type Alice struct {
	Proposer
}

Alice is a Proposer. She proposes the new channel.

func NewAlice

func NewAlice(t *testing.T, setup RoleSetup) *Alice

NewAlice creates a new Proposer that executes the Alice protocol.

func (*Alice) EnableStages added in v0.3.0

func (r *Alice) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Alice) Execute

func (r *Alice) Execute(cfg ExecConfig)

Execute executes the Alice protocol.

func (*Alice) GoHandle added in v0.3.0

func (r *Alice) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Alice) Idxs added in v0.3.0

func (r *Alice) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Alice) LedgerChannelProposal added in v0.4.1

func (r *Alice) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Alice) NewRng added in v0.10.0

func (r *Alice) NewRng() *rand.Rand

func (*Alice) OnNewChannel added in v0.3.0

func (r *Alice) OnNewChannel(callback func(ch *paymentChannel))

func (*Alice) ProposeChannel added in v0.3.0

func (r *Alice) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Alice) RequireNoError added in v0.10.0

func (r *Alice) RequireNoError(err error)

func (*Alice) RequireNoErrorf added in v0.10.0

func (r *Alice) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Alice) RequireTrue added in v0.10.0

func (r *Alice) RequireTrue(b bool)

func (*Alice) RequireTruef added in v0.10.0

func (r *Alice) RequireTruef(b bool, msg string, args ...interface{})

func (*Alice) SetStages added in v0.3.0

func (r *Alice) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Alice) SubChannelProposal added in v0.5.0

func (r *Alice) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Alice) UpdateHandler added in v0.3.0

func (r *Alice) UpdateHandler() *roleUpdateHandler

type AliceBobExecConfig added in v0.5.0

type AliceBobExecConfig struct {
	BaseExecConfig
	NumPayments [2]int      // how many payments each role sends
	TxAmounts   [2]*big.Int // amounts that are to be sent/requested by each role
}

AliceBobExecConfig contains config parameters for Alice and Bob test.

type BalanceReader added in v0.8.0

type BalanceReader interface {
	Balance(a channel.Asset) channel.Bal
}

BalanceReader can be used to read state from a ledger.

type BaseExecConfig added in v0.5.0

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

BaseExecConfig contains base config parameters.

func MakeBaseExecConfig added in v0.5.0

func MakeBaseExecConfig(
	peers [2]wire.Address,
	asset channel.Asset,
	initBals [2]*big.Int,
	app client.ProposalOpts,
) BaseExecConfig

MakeBaseExecConfig creates a new BaseExecConfig.

func (*BaseExecConfig) App added in v0.5.0

App returns the app.

func (*BaseExecConfig) Asset added in v0.5.0

func (c *BaseExecConfig) Asset() channel.Asset

Asset returns the asset.

func (*BaseExecConfig) InitBals added in v0.5.0

func (c *BaseExecConfig) InitBals() [2]*big.Int

InitBals returns the initial balances.

func (*BaseExecConfig) Peers added in v0.5.2

func (c *BaseExecConfig) Peers() [2]wire.Address

Peers returns the peer addresses.

type Bob

type Bob struct {
	Responder
}

Bob is a Responder. He accepts an incoming channel proposal.

func NewBob

func NewBob(t *testing.T, setup RoleSetup) *Bob

NewBob creates a new Responder that executes the Bob protocol.

func (*Bob) EnableStages added in v0.3.0

func (r *Bob) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Bob) Execute

func (r *Bob) Execute(cfg ExecConfig)

Execute executes the Bob protocol.

func (*Bob) GoHandle added in v0.3.0

func (r *Bob) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Bob) Idxs added in v0.3.0

func (r *Bob) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Bob) LedgerChannelProposal added in v0.4.1

func (r *Bob) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Bob) NewRng added in v0.10.0

func (r *Bob) NewRng() *rand.Rand

func (*Bob) OnNewChannel added in v0.3.0

func (r *Bob) OnNewChannel(callback func(ch *paymentChannel))

func (*Bob) ProposeChannel added in v0.3.0

func (r *Bob) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Bob) RequireNoError added in v0.10.0

func (r *Bob) RequireNoError(err error)

func (*Bob) RequireNoErrorf added in v0.10.0

func (r *Bob) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Bob) RequireTrue added in v0.10.0

func (r *Bob) RequireTrue(b bool)

func (*Bob) RequireTruef added in v0.10.0

func (r *Bob) RequireTruef(b bool, msg string, args ...interface{})

func (*Bob) SetStages added in v0.3.0

func (r *Bob) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Bob) SubChannelProposal added in v0.5.0

func (r *Bob) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Bob) UpdateHandler added in v0.3.0

func (r *Bob) UpdateHandler() *roleUpdateHandler

type Carol added in v0.2.0

type Carol struct {
	Responder
	// contains filtered or unexported fields
}

Carol is a Responder. She accepts an incoming channel proposal.

func NewCarol added in v0.2.0

func NewCarol(t *testing.T, setup RoleSetup) *Carol

NewCarol creates a new Responder that executes the Carol protocol.

func (*Carol) EnableStages added in v0.3.0

func (r *Carol) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Carol) Execute added in v0.2.0

func (r *Carol) Execute(cfg ExecConfig)

Execute executes the Carol protocol.

func (*Carol) GoHandle added in v0.3.0

func (r *Carol) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Carol) HandleAdjudicatorEvent added in v0.6.0

func (r *Carol) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)

HandleAdjudicatorEvent is the callback for adjudicator event handling.

func (*Carol) Idxs added in v0.3.0

func (r *Carol) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Carol) LedgerChannelProposal added in v0.4.1

func (r *Carol) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Carol) NewRng added in v0.10.0

func (r *Carol) NewRng() *rand.Rand

func (*Carol) OnNewChannel added in v0.3.0

func (r *Carol) OnNewChannel(callback func(ch *paymentChannel))

func (*Carol) ProposeChannel added in v0.3.0

func (r *Carol) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Carol) RequireNoError added in v0.10.0

func (r *Carol) RequireNoError(err error)

func (*Carol) RequireNoErrorf added in v0.10.0

func (r *Carol) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Carol) RequireTrue added in v0.10.0

func (r *Carol) RequireTrue(b bool)

func (*Carol) RequireTruef added in v0.10.0

func (r *Carol) RequireTruef(b bool, msg string, args ...interface{})

func (*Carol) SetStages added in v0.3.0

func (r *Carol) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Carol) SubChannelProposal added in v0.5.0

func (r *Carol) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Carol) UpdateHandler added in v0.3.0

func (r *Carol) UpdateHandler() *roleUpdateHandler

type Client added in v0.10.2

type Client struct {
	*client.Client
	RoleSetup
	WalletAddress wallet.Address
}

Client is a client used for testing.

func NewClients added in v0.10.4

func NewClients(t *testing.T, rng *rand.Rand, setups []RoleSetup) []*Client

NewClients creates new test clients from role setup specifications.

type DisputeSusie added in v0.8.0

type DisputeSusie struct {
	Proposer
}

DisputeSusie is a Proposer. She proposes the new channel.

func NewDisputeSusie added in v0.8.0

func NewDisputeSusie(t *testing.T, setup RoleSetup) *DisputeSusie

NewDisputeSusie creates a new Proposer that executes the DisputeSusie protocol.

func (*DisputeSusie) EnableStages added in v0.8.0

func (r *DisputeSusie) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*DisputeSusie) Execute added in v0.8.0

func (r *DisputeSusie) Execute(cfg ExecConfig)

Execute executes the DisputeSusie protocol.

func (*DisputeSusie) GoHandle added in v0.8.0

func (r *DisputeSusie) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*DisputeSusie) Idxs added in v0.8.0

func (r *DisputeSusie) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*DisputeSusie) LedgerChannelProposal added in v0.8.0

func (r *DisputeSusie) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*DisputeSusie) NewRng added in v0.10.0

func (r *DisputeSusie) NewRng() *rand.Rand

func (*DisputeSusie) OnNewChannel added in v0.8.0

func (r *DisputeSusie) OnNewChannel(callback func(ch *paymentChannel))

func (*DisputeSusie) ProposeChannel added in v0.8.0

func (r *DisputeSusie) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*DisputeSusie) RequireNoError added in v0.10.0

func (r *DisputeSusie) RequireNoError(err error)

func (*DisputeSusie) RequireNoErrorf added in v0.10.0

func (r *DisputeSusie) RequireNoErrorf(err error, msg string, args ...interface{})

func (*DisputeSusie) RequireTrue added in v0.10.0

func (r *DisputeSusie) RequireTrue(b bool)

func (*DisputeSusie) RequireTruef added in v0.10.0

func (r *DisputeSusie) RequireTruef(b bool, msg string, args ...interface{})

func (*DisputeSusie) SetStages added in v0.8.0

func (r *DisputeSusie) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*DisputeSusie) SubChannelProposal added in v0.8.0

func (r *DisputeSusie) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*DisputeSusie) UpdateHandler added in v0.8.0

func (r *DisputeSusie) UpdateHandler() *roleUpdateHandler

type DisputeSusieTimExecConfig added in v0.8.0

type DisputeSusieTimExecConfig struct {
	BaseExecConfig
	SubChannelFunds [2]*big.Int // sub-channel funding amounts
	TxAmount        *big.Int    // transaction amount
}

DisputeSusieTimExecConfig contains config parameters for sub-channel dispute test.

type DisputeTim added in v0.8.0

type DisputeTim struct {
	Responder
	// contains filtered or unexported fields
}

DisputeTim is a Responder. He accepts incoming channel proposals and updates.

func NewDisputeTim added in v0.8.0

func NewDisputeTim(t *testing.T, setup RoleSetup) *DisputeTim

NewDisputeTim creates a new Responder that executes the DisputeTim protocol.

func (*DisputeTim) EnableStages added in v0.8.0

func (r *DisputeTim) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*DisputeTim) Execute added in v0.8.0

func (r *DisputeTim) Execute(cfg ExecConfig)

Execute executes the DisputeTim protocol.

func (*DisputeTim) GoHandle added in v0.8.0

func (r *DisputeTim) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*DisputeTim) HandleAdjudicatorEvent added in v0.8.0

func (r *DisputeTim) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)

HandleAdjudicatorEvent is the callback for adjudicator event handling.

func (*DisputeTim) Idxs added in v0.8.0

func (r *DisputeTim) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*DisputeTim) LedgerChannelProposal added in v0.8.0

func (r *DisputeTim) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*DisputeTim) NewRng added in v0.10.0

func (r *DisputeTim) NewRng() *rand.Rand

func (*DisputeTim) OnNewChannel added in v0.8.0

func (r *DisputeTim) OnNewChannel(callback func(ch *paymentChannel))

func (*DisputeTim) ProposeChannel added in v0.8.0

func (r *DisputeTim) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*DisputeTim) RequireNoError added in v0.10.0

func (r *DisputeTim) RequireNoError(err error)

func (*DisputeTim) RequireNoErrorf added in v0.10.0

func (r *DisputeTim) RequireNoErrorf(err error, msg string, args ...interface{})

func (*DisputeTim) RequireTrue added in v0.10.0

func (r *DisputeTim) RequireTrue(b bool)

func (*DisputeTim) RequireTruef added in v0.10.0

func (r *DisputeTim) RequireTruef(b bool, msg string, args ...interface{})

func (*DisputeTim) SetStages added in v0.8.0

func (r *DisputeTim) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*DisputeTim) SubChannelProposal added in v0.8.0

func (r *DisputeTim) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*DisputeTim) UpdateHandler added in v0.8.0

func (r *DisputeTim) UpdateHandler() *roleUpdateHandler

type ExecConfig

type ExecConfig interface {
	Peers() [2]wire.Address   // must match the RoleSetup.Identity's
	Asset() channel.Asset     // single Asset to use in this channel
	InitBals() [2]*big.Int    // channel deposit of each role
	App() client.ProposalOpts // must be either WithApp or WithoutApp
}

ExecConfig contains additional config parameters for the tests.

type Executer added in v0.2.0

type Executer interface {
	// Execute executes the protocol according to the given configuration.
	Execute(cfg ExecConfig)
	// EnableStages enables role synchronization.
	EnableStages() Stages
	// SetStages enables role synchronization using the given stages.
	SetStages(Stages)
	// Errors returns the error channel.
	Errors() <-chan error
}

An Executer is a Role that can execute a protocol.

type FailingFunder added in v0.10.4

type FailingFunder struct{}

FailingFunder is a funder that always fails and is used for testing.

func (FailingFunder) Fund added in v0.10.4

Fund returns an error to simulate failed funding.

type FundSetup added in v0.10.4

type FundSetup struct {
	ChallengeDuration uint64
	FridaInitBal      channel.Bal
	FredInitBal       channel.Bal
	BalanceDelta      channel.Bal
}

FundSetup represents the fund recovery test parameters.

type LedgerID added in v0.10.0

type LedgerID string

LedgerID is the type of the ledger identifier.

func (LedgerID) MapKey added in v0.10.0

func (id LedgerID) MapKey() multi.LedgerIDMapKey

MapKey returns the map key representation of the ledger identifier.

type Mallory added in v0.2.0

type Mallory struct {
	Proposer
}

Mallory is a test client role. She proposes the new channel.

func NewMallory added in v0.2.0

func NewMallory(t *testing.T, setup RoleSetup) *Mallory

NewMallory creates a new party that executes the Mallory protocol.

func (*Mallory) EnableStages added in v0.3.0

func (r *Mallory) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Mallory) Execute added in v0.2.0

func (r *Mallory) Execute(cfg ExecConfig)

Execute executes the Mallory protocol.

func (*Mallory) GoHandle added in v0.3.0

func (r *Mallory) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Mallory) Idxs added in v0.3.0

func (r *Mallory) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Mallory) LedgerChannelProposal added in v0.4.1

func (r *Mallory) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Mallory) NewRng added in v0.10.0

func (r *Mallory) NewRng() *rand.Rand

func (*Mallory) OnNewChannel added in v0.3.0

func (r *Mallory) OnNewChannel(callback func(ch *paymentChannel))

func (*Mallory) ProposeChannel added in v0.3.0

func (r *Mallory) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Mallory) RequireNoError added in v0.10.0

func (r *Mallory) RequireNoError(err error)

func (*Mallory) RequireNoErrorf added in v0.10.0

func (r *Mallory) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Mallory) RequireTrue added in v0.10.0

func (r *Mallory) RequireTrue(b bool)

func (*Mallory) RequireTruef added in v0.10.0

func (r *Mallory) RequireTruef(b bool, msg string, args ...interface{})

func (*Mallory) SetStages added in v0.3.0

func (r *Mallory) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Mallory) SubChannelProposal added in v0.5.0

func (r *Mallory) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Mallory) UpdateHandler added in v0.3.0

func (r *Mallory) UpdateHandler() *roleUpdateHandler

type MalloryCarolExecConfig added in v0.5.0

type MalloryCarolExecConfig struct {
	BaseExecConfig
	NumPayments [2]int      // how many payments each role sends
	TxAmounts   [2]*big.Int // amounts that are to be sent/requested by each role
}

MalloryCarolExecConfig contains config parameters for Mallory and Carol test.

type MockAdjudicator added in v0.10.4

type MockAdjudicator struct {
	*MockBackend
	// contains filtered or unexported fields
}

MockAdjudicator is an adjudicator used for testing.

func (*MockAdjudicator) Withdraw added in v0.10.4

func (a *MockAdjudicator) Withdraw(ctx context.Context, req channel.AdjudicatorReq, subStates channel.StateMap) error

Withdraw withdraws the balances of the given channel and its sub-channels.

type MockBackend added in v0.7.0

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

MockBackend is a mocked backend useful for testing.

func NewMockBackend added in v0.7.0

func NewMockBackend(rng *rand.Rand, id string) *MockBackend

NewMockBackend creates a new backend object.

func (*MockBackend) Balance added in v0.8.0

func (b *MockBackend) Balance(p wallet.Address, a channel.Asset) *big.Int

Balance returns the balance for the participant and asset.

func (*MockBackend) Fund added in v0.7.0

Fund funds the channel.

func (*MockBackend) ID added in v0.10.0

func (b *MockBackend) ID() LedgerID

ID returns the ledger's identifier.

func (*MockBackend) NewAdjudicator added in v0.10.4

func (b *MockBackend) NewAdjudicator(acc wallet.Address) *MockAdjudicator

NewAdjudicator creates a new MockAdjudicator.

func (*MockBackend) NewBalanceReader added in v0.10.4

func (b *MockBackend) NewBalanceReader(acc wallet.Address) *MockBalanceReader

NewBalanceReader creates balance for the given account.

func (*MockBackend) NewFunder added in v0.10.4

func (b *MockBackend) NewFunder(acc wallet.Address) *MockFunder

NewFunder returns a new MockFunder.

func (*MockBackend) Progress added in v0.7.0

func (b *MockBackend) Progress(_ context.Context, req channel.ProgressReq) error

Progress progresses the channel state.

func (*MockBackend) Register added in v0.7.0

func (b *MockBackend) Register(_ context.Context, req channel.AdjudicatorReq, subChannels []channel.SignedState) error

Register registers the channel.

func (*MockBackend) Subscribe added in v0.7.0

Subscribe creates an event subscription.

func (*MockBackend) Withdraw added in v0.7.0

func (b *MockBackend) Withdraw(_ context.Context, req channel.AdjudicatorReq, subStates channel.StateMap, acc wallet.Address) error

Withdraw withdraws the channel funds.

type MockBalanceReader added in v0.10.4

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

MockBalanceReader is a balance reader used for testing. At initialization, it is associated with a given account.

func (*MockBalanceReader) Balance added in v0.10.4

func (br *MockBalanceReader) Balance(asset channel.Asset) channel.Bal

Balance returns the balance of the associated account for the given asset.

type MockFunder added in v0.10.4

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

MockFunder is a funder used for testing.

func (*MockFunder) Fund added in v0.10.4

func (f *MockFunder) Fund(ctx context.Context, req channel.FundingReq) error

Fund funds a given channel.

type MockSubscription added in v0.9.1

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

MockSubscription is a subscription for MockBackend.

func NewMockSubscription added in v0.9.1

func NewMockSubscription(ctx context.Context) *MockSubscription

NewMockSubscription creates a new MockSubscription.

func (*MockSubscription) Close added in v0.9.1

func (s *MockSubscription) Close() error

Close closes the subscription.

func (*MockSubscription) Err added in v0.9.1

func (s *MockSubscription) Err() error

Err returns the subscription's error after it has failed.

func (*MockSubscription) Next added in v0.9.1

Next returns the next event.

type MultiLedgerAsset added in v0.10.0

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

MultiLedgerAsset is a multi-ledger asset.

func NewMultiLedgerAsset added in v0.10.0

func NewMultiLedgerAsset(id LedgerID, asset channel.Asset) *MultiLedgerAsset

NewMultiLedgerAsset returns a new multi-ledger asset.

func (*MultiLedgerAsset) Equal added in v0.10.0

func (a *MultiLedgerAsset) Equal(b channel.Asset) bool

Equal returns whether the two assets are equal.

func (*MultiLedgerAsset) LedgerID added in v0.10.0

func (a *MultiLedgerAsset) LedgerID() multi.LedgerID

LedgerID returns the asset's ledger ID.

func (*MultiLedgerAsset) MarshalBinary added in v0.10.0

func (a *MultiLedgerAsset) MarshalBinary() ([]byte, error)

MarshalBinary encodes the asset to its byte representation.

func (*MultiLedgerAsset) UnmarshalBinary added in v0.10.0

func (a *MultiLedgerAsset) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the asset from its byte representation.

type MultiLedgerClient added in v0.10.4

type MultiLedgerClient struct {
	*client.Client
	WireAddress                    wire.Address
	WalletAddress                  wallet.Address
	Events                         chan channel.AdjudicatorEvent
	Adjudicator1, Adjudicator2     channel.Adjudicator
	BalanceReader1, BalanceReader2 BalanceReader
}

MultiLedgerClient represents a test client.

func (MultiLedgerClient) HandleAdjudicatorEvent added in v0.10.4

func (c MultiLedgerClient) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)

HandleAdjudicatorEvent handles an incoming adjudicator event.

type MultiLedgerSetup added in v0.10.2

type MultiLedgerSetup struct {
	Client1, Client2 MultiLedgerClient
	Asset1, Asset2   multi.Asset
	InitBalances     channel.Balances
	UpdateBalances1  channel.Balances
	UpdateBalances2  channel.Balances
	BalanceDelta     channel.Bal // Delta the final balances can be off due to gas costs for example.
}

MultiLedgerSetup is the setup of a multi-ledger test.

func SetupMultiLedgerTest added in v0.10.0

func SetupMultiLedgerTest(t *testing.T) MultiLedgerSetup

SetupMultiLedgerTest sets up a multi-ledger test.

type Paul added in v0.6.0

type Paul struct {
	Proposer
	Watcher
}

Paul is a test client role. He proposes the new channel.

func NewPaul added in v0.6.0

func NewPaul(t *testing.T, setup RoleSetup) *Paul

NewPaul creates a new party that executes the Paul protocol.

func (*Paul) EnableStages added in v0.6.0

func (r *Paul) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Paul) Execute added in v0.6.0

func (r *Paul) Execute(cfg ExecConfig)

Execute executes the Paul protocol.

func (*Paul) GoHandle added in v0.6.0

func (r *Paul) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Paul) Idxs added in v0.6.0

func (r *Paul) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Paul) LedgerChannelProposal added in v0.6.0

func (r *Paul) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Paul) NewRng added in v0.10.0

func (r *Paul) NewRng() *rand.Rand

func (*Paul) OnNewChannel added in v0.6.0

func (r *Paul) OnNewChannel(callback func(ch *paymentChannel))

func (*Paul) ProposeChannel added in v0.6.0

func (r *Paul) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Paul) RequireNoError added in v0.10.0

func (r *Paul) RequireNoError(err error)

func (*Paul) RequireNoErrorf added in v0.10.0

func (r *Paul) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Paul) RequireTrue added in v0.10.0

func (r *Paul) RequireTrue(b bool)

func (*Paul) RequireTruef added in v0.10.0

func (r *Paul) RequireTruef(b bool, msg string, args ...interface{})

func (*Paul) SetStages added in v0.6.0

func (r *Paul) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Paul) SubChannelProposal added in v0.6.0

func (r *Paul) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Paul) UpdateHandler added in v0.6.0

func (r *Paul) UpdateHandler() *roleUpdateHandler

type Paula added in v0.6.0

type Paula struct {
	Responder
	Watcher
}

Paula is a test client role. She proposes the new channel.

func NewPaula added in v0.6.0

func NewPaula(t *testing.T, setup RoleSetup) *Paula

NewPaula creates a new party that executes the Paula protocol.

func (*Paula) EnableStages added in v0.6.0

func (r *Paula) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Paula) Execute added in v0.6.0

func (r *Paula) Execute(cfg ExecConfig)

Execute executes the Paula protocol.

func (*Paula) GoHandle added in v0.6.0

func (r *Paula) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Paula) Idxs added in v0.6.0

func (r *Paula) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Paula) LedgerChannelProposal added in v0.6.0

func (r *Paula) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Paula) NewRng added in v0.10.0

func (r *Paula) NewRng() *rand.Rand

func (*Paula) OnNewChannel added in v0.6.0

func (r *Paula) OnNewChannel(callback func(ch *paymentChannel))

func (*Paula) ProposeChannel added in v0.6.0

func (r *Paula) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Paula) RequireNoError added in v0.10.0

func (r *Paula) RequireNoError(err error)

func (*Paula) RequireNoErrorf added in v0.10.0

func (r *Paula) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Paula) RequireTrue added in v0.10.0

func (r *Paula) RequireTrue(b bool)

func (*Paula) RequireTruef added in v0.10.0

func (r *Paula) RequireTruef(b bool, msg string, args ...interface{})

func (*Paula) SetStages added in v0.6.0

func (r *Paula) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Paula) SubChannelProposal added in v0.6.0

func (r *Paula) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Paula) UpdateHandler added in v0.6.0

func (r *Paula) UpdateHandler() *roleUpdateHandler

type Petra added in v0.3.0

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

Petra is the Proposer in a Persistence test.

func NewPetra added in v0.3.0

func NewPetra(t *testing.T, setup RoleSetup) *Petra

NewPetra creates a new Proposer that executes the Petra protocol.

func (*Petra) Errors added in v0.10.1

func (r *Petra) Errors() <-chan error

Errors returns the error channel.

func (*Petra) Execute added in v0.3.0

func (r *Petra) Execute(cfg ExecConfig)

Execute executes the Petra protocol.

func (*Petra) ReplaceClient added in v0.3.0

func (r *Petra) ReplaceClient()

ReplaceClient replaces the client instance of the Role. Useful for persistence testing.

type ProgressionExecConfig added in v0.6.0

type ProgressionExecConfig struct {
	BaseExecConfig
}

ProgressionExecConfig contains config parameters for the progression test.

type Proposer added in v0.3.0

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

Proposer is a test client role. He proposes the new channel.

func NewProposer added in v0.3.0

func NewProposer(t *testing.T, setup RoleSetup, numStages int) *Proposer

NewProposer creates a new party that executes the Proposer protocol.

func (*Proposer) EnableStages added in v0.3.0

func (r *Proposer) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Proposer) Errors added in v0.10.1

func (r *Proposer) Errors() <-chan error

Errors returns the error channel.

func (*Proposer) Execute added in v0.3.0

func (r *Proposer) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel))

Execute executes the Proposer protocol.

func (*Proposer) GoHandle added in v0.3.0

func (r *Proposer) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Proposer) Idxs added in v0.3.0

func (r *Proposer) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Proposer) LedgerChannelProposal added in v0.4.1

func (r *Proposer) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Proposer) NewRng added in v0.10.0

func (r *Proposer) NewRng() *rand.Rand

func (*Proposer) OnNewChannel added in v0.3.0

func (r *Proposer) OnNewChannel(callback func(ch *paymentChannel))

func (*Proposer) ProposeChannel added in v0.3.0

func (r *Proposer) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Proposer) RequireNoError added in v0.10.0

func (r *Proposer) RequireNoError(err error)

func (*Proposer) RequireNoErrorf added in v0.10.0

func (r *Proposer) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Proposer) RequireTrue added in v0.10.0

func (r *Proposer) RequireTrue(b bool)

func (*Proposer) RequireTruef added in v0.10.0

func (r *Proposer) RequireTruef(b bool, msg string, args ...interface{})

func (*Proposer) SetStages added in v0.3.0

func (r *Proposer) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Proposer) SubChannelProposal added in v0.5.0

func (r *Proposer) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Proposer) UpdateHandler added in v0.3.0

func (r *Proposer) UpdateHandler() *roleUpdateHandler

type Responder added in v0.3.0

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

Responder is a test client role. He accepts an incoming channel proposal.

func NewResponder added in v0.3.0

func NewResponder(t *testing.T, setup RoleSetup, numStages int) *Responder

NewResponder creates a new party that executes the Responder protocol.

func (*Responder) EnableStages added in v0.3.0

func (r *Responder) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Responder) Errors added in v0.10.1

func (r *Responder) Errors() <-chan error

Errors returns the error channel.

func (*Responder) Execute added in v0.3.0

func (r *Responder) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel, *acceptNextPropHandler))

Execute executes the Responder protocol.

func (*Responder) GoHandle added in v0.3.0

func (r *Responder) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Responder) Idxs added in v0.3.0

func (r *Responder) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Responder) LedgerChannelProposal added in v0.4.1

func (r *Responder) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Responder) NewRng added in v0.10.0

func (r *Responder) NewRng() *rand.Rand

func (*Responder) OnNewChannel added in v0.3.0

func (r *Responder) OnNewChannel(callback func(ch *paymentChannel))

func (*Responder) ProposeChannel added in v0.3.0

func (r *Responder) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Responder) RequireNoError added in v0.10.0

func (r *Responder) RequireNoError(err error)

func (*Responder) RequireNoErrorf added in v0.10.0

func (r *Responder) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Responder) RequireTrue added in v0.10.0

func (r *Responder) RequireTrue(b bool)

func (*Responder) RequireTruef added in v0.10.0

func (r *Responder) RequireTruef(b bool, msg string, args ...interface{})

func (*Responder) SetStages added in v0.3.0

func (r *Responder) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Responder) SubChannelProposal added in v0.5.0

func (r *Responder) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Responder) UpdateHandler added in v0.3.0

func (r *Responder) UpdateHandler() *roleUpdateHandler

type Robert added in v0.3.0

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

Robert is the Responder in a persistence test.

func NewRobert added in v0.3.0

func NewRobert(t *testing.T, setup RoleSetup) *Robert

NewRobert creates a new Responder that executes the Robert protocol.

func (*Robert) Errors added in v0.10.1

func (r *Robert) Errors() <-chan error

Errors returns the error channel.

func (*Robert) Execute added in v0.3.0

func (r *Robert) Execute(cfg ExecConfig)

Execute executes the Robert protocol.

func (*Robert) ReplaceClient added in v0.3.0

func (r *Robert) ReplaceClient()

ReplaceClient replaces the client instance of the Role. Useful for persistence testing.

type RoleSetup

type RoleSetup struct {
	Name              string
	Identity          wire.Account
	Bus               wire.Bus
	Funder            channel.Funder
	Adjudicator       channel.Adjudicator
	Watcher           watcher.Watcher
	Wallet            wallettest.Wallet
	PR                persistence.PersistRestorer // Optional PersistRestorer
	Timeout           time.Duration               // Timeout waiting for other role, not challenge duration
	BalanceReader     BalanceReader
	ChallengeDuration uint64
	Errors            chan error
}

RoleSetup contains the injectables for setting up the client.

type Stages added in v0.2.0

type Stages = []sync.WaitGroup

Stages are used to synchronize multiple roles.

type Susie added in v0.5.0

type Susie struct {
	Proposer
}

Susie is a Proposer. She proposes the new channel.

func NewSusie added in v0.5.0

func NewSusie(t *testing.T, setup RoleSetup) *Susie

NewSusie creates a new Proposer that executes the Susie protocol.

func (*Susie) EnableStages added in v0.5.0

func (r *Susie) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Susie) Execute added in v0.5.0

func (r *Susie) Execute(cfg ExecConfig)

Execute executes the Susie protocol.

func (*Susie) GoHandle added in v0.5.0

func (r *Susie) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Susie) Idxs added in v0.5.0

func (r *Susie) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Susie) LedgerChannelProposal added in v0.5.0

func (r *Susie) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Susie) NewRng added in v0.10.0

func (r *Susie) NewRng() *rand.Rand

func (*Susie) OnNewChannel added in v0.5.0

func (r *Susie) OnNewChannel(callback func(ch *paymentChannel))

func (*Susie) ProposeChannel added in v0.5.0

func (r *Susie) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Susie) RequireNoError added in v0.10.0

func (r *Susie) RequireNoError(err error)

func (*Susie) RequireNoErrorf added in v0.10.0

func (r *Susie) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Susie) RequireTrue added in v0.10.0

func (r *Susie) RequireTrue(b bool)

func (*Susie) RequireTruef added in v0.10.0

func (r *Susie) RequireTruef(b bool, msg string, args ...interface{})

func (*Susie) SetStages added in v0.5.0

func (r *Susie) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Susie) SubChannelProposal added in v0.5.0

func (r *Susie) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Susie) UpdateHandler added in v0.5.0

func (r *Susie) UpdateHandler() *roleUpdateHandler

type SusieTimExecConfig added in v0.5.0

type SusieTimExecConfig struct {
	BaseExecConfig
	SubChannelFunds    [][2]*big.Int       // sub-channel funding amounts, also determines number of sub-channels, must be at least 1
	SubSubChannelFunds [][2]*big.Int       // sub-sub-channel funding amounts, also determines number of sub-sub-channels
	LeafChannelApp     client.ProposalOpts // app used in the leaf channels
	TxAmount           *big.Int            // transaction amount
}

SusieTimExecConfig contains config parameters for Susie and Tim test.

func NewSusieTimExecConfig added in v0.5.0

func NewSusieTimExecConfig(
	base BaseExecConfig,
	numSubChannels int,
	numSubSubChannels int,
	subChannelFunds [][2]*big.Int,
	subSubChannelFunds [][2]*big.Int,
	leafChannelApp client.ProposalOpts,
	txAmount *big.Int,
) *SusieTimExecConfig

NewSusieTimExecConfig creates a new object from the given parameters.

type Tim added in v0.5.0

type Tim struct {
	Responder
}

Tim is a Responder. He accepts incoming channel proposals and updates.

func NewTim added in v0.5.0

func NewTim(t *testing.T, setup RoleSetup) *Tim

NewTim creates a new Responder that executes the Tim protocol.

func (*Tim) EnableStages added in v0.5.0

func (r *Tim) EnableStages() Stages

EnableStages optionally enables the synchronization of this role at different stages of the Execute protocol. EnableStages should be called on a single role and the resulting slice set on all remaining roles by calling SetStages on them.

func (*Tim) Execute added in v0.5.0

func (r *Tim) Execute(cfg ExecConfig)

Execute executes the Tim protocol.

func (*Tim) GoHandle added in v0.5.0

func (r *Tim) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())

GoHandle starts the handler routine on the current client and returns a wait() function with which it can be waited for the handler routine to stop.

func (*Tim) Idxs added in v0.5.0

func (r *Tim) Idxs(peers [2]wire.Address) (our, their channel.Index)

Idxs maps the passed addresses to the indices in the 2-party-channel. If the setup's Identity is not found in peers, Idxs panics.

func (*Tim) LedgerChannelProposal added in v0.5.0

func (r *Tim) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg

func (*Tim) NewRng added in v0.10.0

func (r *Tim) NewRng() *rand.Rand

func (*Tim) OnNewChannel added in v0.5.0

func (r *Tim) OnNewChannel(callback func(ch *paymentChannel))

func (*Tim) ProposeChannel added in v0.5.0

func (r *Tim) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)

ProposeChannel sends the channel proposal req. It times out after the timeout specified in the Role's setup.

func (*Tim) RequireNoError added in v0.10.0

func (r *Tim) RequireNoError(err error)

func (*Tim) RequireNoErrorf added in v0.10.0

func (r *Tim) RequireNoErrorf(err error, msg string, args ...interface{})

func (*Tim) RequireTrue added in v0.10.0

func (r *Tim) RequireTrue(b bool)

func (*Tim) RequireTruef added in v0.10.0

func (r *Tim) RequireTruef(b bool, msg string, args ...interface{})

func (*Tim) SetStages added in v0.5.0

func (r *Tim) SetStages(st Stages)

SetStages optionally sets a slice of WaitGroup barriers to wait on at different stages of the Execute protocol. It should be created by any role by calling EnableStages().

func (*Tim) SubChannelProposal added in v0.5.0

func (r *Tim) SubChannelProposal(
	rng io.Reader,
	cfg ExecConfig,
	parent *client.Channel,
	initBals *channel.Allocation,
	app client.ProposalOpts,
) *client.SubChannelProposalMsg

func (*Tim) UpdateHandler added in v0.5.0

func (r *Tim) UpdateHandler() *roleUpdateHandler

type VirtualChannelBalances added in v0.10.5

type VirtualChannelBalances struct {
	InitBalsAliceIngrid []*big.Int
	InitBalsBobIngrid   []*big.Int
	InitBalsAliceBob    []*big.Int
	VirtualBalsUpdated  []*big.Int
	FinalBalsAlice      []*big.Int
	FinalBalsBob        []*big.Int
}

VirtualChannelBalances contains a description of the balances that will be used during a virtual channel test.

type VirtualChannelSetup added in v0.10.5

type VirtualChannelSetup struct {
	Clients            [3]RoleSetup
	ChallengeDuration  uint64
	Asset              channel.Asset
	Balances           VirtualChannelBalances
	BalanceDelta       channel.Bal
	Rng                *rand.Rand
	WaitWatcherTimeout time.Duration
}

VirtualChannelSetup contains the setup for a virtual channel test.

type Watcher added in v0.6.0

type Watcher struct {
	log.Logger
	// contains filtered or unexported fields
}

Watcher is a client that handles adjudicator events.

func (*Watcher) HandleAdjudicatorEvent added in v0.6.0

func (w *Watcher) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)

HandleAdjudicatorEvent is the callback for adjudicator event handling.

Jump to

Keyboard shortcuts

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