Documentation ¶
Overview ¶
Package test contains testing setup types and functions for package client.
Package test contains helpers for testing the client
Index ¶
- func AlwaysAcceptChannelHandler(ctx context.Context, addr wallet.Address, channels chan *client.Channel, ...) client.ProposalHandlerFunc
- func AlwaysAcceptUpdateHandler(ctx context.Context, errs chan error) client.UpdateHandlerFunc
- func AlwaysRejectChannelHandler(ctx context.Context, errs chan<- error) client.ProposalHandlerFunc
- func AlwaysRejectUpdateHandler(ctx context.Context, errs chan error) client.UpdateHandlerFunc
- func ChannelSyncMsgSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))
- func EqualBalancesWithDelta(bals1 channel.Balances, bals2 channel.Balances, delta channel.Bal) bool
- func ExecuteTwoPartyTest(ctx context.Context, t *testing.T, role [2]Executer, cfg ExecConfig)
- func NewRandomLedgerChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) *client.LedgerChannelProposalMsg
- func NewRandomLedgerChannelProposalBy(rng *rand.Rand, proposer wallet.Address, opts ...client.ProposalOpts) *client.LedgerChannelProposalMsg
- func NewRandomSubChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) (*client.SubChannelProposalMsg, error)
- func NewRandomVirtualChannelProposal(rng *rand.Rand, opts ...client.ProposalOpts) (*client.VirtualChannelProposalMsg, error)
- func ProposalMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))
- func TestFundRecovery(ctx context.Context, t *testing.T, params FundSetup, ...)
- func TestMultiLedgerDispute(ctx context.Context, t *testing.T, mlt MultiLedgerSetup, ...)
- func TestMultiLedgerHappy(ctx context.Context, t *testing.T, mlt MultiLedgerSetup, ...)
- func TestVirtualChannelDispute(ctx context.Context, t *testing.T, setup VirtualChannelSetup)
- func TestVirtualChannelOptimistic(ctx context.Context, t *testing.T, setup VirtualChannelSetup)
- func UpdateMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))
- type Alice
- func (r *Alice) EnableStages() Stages
- func (r *Alice) Execute(cfg ExecConfig)
- func (r *Alice) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Alice) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Alice) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Alice) NewRng() *rand.Rand
- func (r *Alice) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Alice) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Alice) RequireNoError(err error)
- func (r *Alice) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Alice) RequireTrue(b bool)
- func (r *Alice) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Alice) SetStages(st Stages)
- func (r *Alice) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Alice) UpdateHandler() *roleUpdateHandler
- type AliceBobExecConfig
- type BalanceReader
- type BaseExecConfig
- type Bob
- func (r *Bob) EnableStages() Stages
- func (r *Bob) Execute(cfg ExecConfig)
- func (r *Bob) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Bob) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Bob) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Bob) NewRng() *rand.Rand
- func (r *Bob) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Bob) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Bob) RequireNoError(err error)
- func (r *Bob) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Bob) RequireTrue(b bool)
- func (r *Bob) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Bob) SetStages(st Stages)
- func (r *Bob) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Bob) UpdateHandler() *roleUpdateHandler
- type Carol
- func (r *Carol) EnableStages() Stages
- func (r *Carol) Execute(cfg ExecConfig)
- func (r *Carol) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Carol) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)
- func (r *Carol) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Carol) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Carol) NewRng() *rand.Rand
- func (r *Carol) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Carol) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Carol) RequireNoError(err error)
- func (r *Carol) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Carol) RequireTrue(b bool)
- func (r *Carol) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Carol) SetStages(st Stages)
- func (r *Carol) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Carol) UpdateHandler() *roleUpdateHandler
- type Client
- type DisputeSusie
- func (r *DisputeSusie) EnableStages() Stages
- func (r *DisputeSusie) Execute(cfg ExecConfig)
- func (r *DisputeSusie) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *DisputeSusie) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *DisputeSusie) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *DisputeSusie) NewRng() *rand.Rand
- func (r *DisputeSusie) OnNewChannel(callback func(ch *paymentChannel))
- func (r *DisputeSusie) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *DisputeSusie) RequireNoError(err error)
- func (r *DisputeSusie) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *DisputeSusie) RequireTrue(b bool)
- func (r *DisputeSusie) RequireTruef(b bool, msg string, args ...interface{})
- func (r *DisputeSusie) SetStages(st Stages)
- func (r *DisputeSusie) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *DisputeSusie) UpdateHandler() *roleUpdateHandler
- type DisputeSusieTimExecConfig
- type DisputeTim
- func (r *DisputeTim) EnableStages() Stages
- func (r *DisputeTim) Execute(cfg ExecConfig)
- func (r *DisputeTim) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *DisputeTim) HandleAdjudicatorEvent(e channel.AdjudicatorEvent)
- func (r *DisputeTim) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *DisputeTim) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *DisputeTim) NewRng() *rand.Rand
- func (r *DisputeTim) OnNewChannel(callback func(ch *paymentChannel))
- func (r *DisputeTim) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *DisputeTim) RequireNoError(err error)
- func (r *DisputeTim) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *DisputeTim) RequireTrue(b bool)
- func (r *DisputeTim) RequireTruef(b bool, msg string, args ...interface{})
- func (r *DisputeTim) SetStages(st Stages)
- func (r *DisputeTim) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *DisputeTim) UpdateHandler() *roleUpdateHandler
- type ExecConfig
- type Executer
- type FailingFunder
- type FundSetup
- type LedgerID
- type Mallory
- func (r *Mallory) EnableStages() Stages
- func (r *Mallory) Execute(cfg ExecConfig)
- func (r *Mallory) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Mallory) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Mallory) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Mallory) NewRng() *rand.Rand
- func (r *Mallory) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Mallory) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Mallory) RequireNoError(err error)
- func (r *Mallory) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Mallory) RequireTrue(b bool)
- func (r *Mallory) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Mallory) SetStages(st Stages)
- func (r *Mallory) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Mallory) UpdateHandler() *roleUpdateHandler
- type MalloryCarolExecConfig
- type MockAdjudicator
- type MockBackend
- func (b *MockBackend) Balance(p wallet.Address, a channel.Asset) *big.Int
- func (b *MockBackend) Fund(ctx context.Context, req channel.FundingReq, acc wallet.Address) error
- func (b *MockBackend) ID() LedgerID
- func (b *MockBackend) NewAdjudicator(acc wallet.Address) *MockAdjudicator
- func (b *MockBackend) NewBalanceReader(acc wallet.Address) *MockBalanceReader
- func (b *MockBackend) NewFunder(acc wallet.Address) *MockFunder
- func (b *MockBackend) Progress(_ context.Context, req channel.ProgressReq) error
- func (b *MockBackend) Register(_ context.Context, req channel.AdjudicatorReq, ...) error
- func (b *MockBackend) Subscribe(ctx context.Context, chID channel.ID) (channel.AdjudicatorSubscription, error)
- func (b *MockBackend) Withdraw(_ context.Context, req channel.AdjudicatorReq, subStates channel.StateMap, ...) error
- type MockBalanceReader
- type MockFunder
- type MockSubscription
- type MultiLedgerAsset
- type MultiLedgerClient
- type MultiLedgerSetup
- type Paul
- func (r *Paul) EnableStages() Stages
- func (r *Paul) Execute(cfg ExecConfig)
- func (r *Paul) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Paul) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Paul) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Paul) NewRng() *rand.Rand
- func (r *Paul) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Paul) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Paul) RequireNoError(err error)
- func (r *Paul) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Paul) RequireTrue(b bool)
- func (r *Paul) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Paul) SetStages(st Stages)
- func (r *Paul) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Paul) UpdateHandler() *roleUpdateHandler
- type Paula
- func (r *Paula) EnableStages() Stages
- func (r *Paula) Execute(cfg ExecConfig)
- func (r *Paula) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Paula) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Paula) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Paula) NewRng() *rand.Rand
- func (r *Paula) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Paula) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Paula) RequireNoError(err error)
- func (r *Paula) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Paula) RequireTrue(b bool)
- func (r *Paula) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Paula) SetStages(st Stages)
- func (r *Paula) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Paula) UpdateHandler() *roleUpdateHandler
- type Petra
- type ProgressionExecConfig
- type Proposer
- func (r *Proposer) EnableStages() Stages
- func (r *Proposer) Errors() <-chan error
- func (r *Proposer) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel))
- func (r *Proposer) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Proposer) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Proposer) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Proposer) NewRng() *rand.Rand
- func (r *Proposer) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Proposer) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Proposer) RequireNoError(err error)
- func (r *Proposer) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Proposer) RequireTrue(b bool)
- func (r *Proposer) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Proposer) SetStages(st Stages)
- func (r *Proposer) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Proposer) UpdateHandler() *roleUpdateHandler
- type Responder
- func (r *Responder) EnableStages() Stages
- func (r *Responder) Errors() <-chan error
- func (r *Responder) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel, *acceptNextPropHandler))
- func (r *Responder) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Responder) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Responder) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Responder) NewRng() *rand.Rand
- func (r *Responder) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Responder) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Responder) RequireNoError(err error)
- func (r *Responder) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Responder) RequireTrue(b bool)
- func (r *Responder) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Responder) SetStages(st Stages)
- func (r *Responder) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Responder) UpdateHandler() *roleUpdateHandler
- type Robert
- type RoleSetup
- type Stages
- type Susie
- func (r *Susie) EnableStages() Stages
- func (r *Susie) Execute(cfg ExecConfig)
- func (r *Susie) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Susie) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Susie) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Susie) NewRng() *rand.Rand
- func (r *Susie) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Susie) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Susie) RequireNoError(err error)
- func (r *Susie) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Susie) RequireTrue(b bool)
- func (r *Susie) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Susie) SetStages(st Stages)
- func (r *Susie) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Susie) UpdateHandler() *roleUpdateHandler
- type SusieTimExecConfig
- type Tim
- func (r *Tim) EnableStages() Stages
- func (r *Tim) Execute(cfg ExecConfig)
- func (r *Tim) GoHandle(rng *rand.Rand) (h *acceptNextPropHandler, wait func())
- func (r *Tim) Idxs(peers [2]wire.Address) (our, their channel.Index)
- func (r *Tim) LedgerChannelProposal(rng *rand.Rand, cfg ExecConfig) *client.LedgerChannelProposalMsg
- func (r *Tim) NewRng() *rand.Rand
- func (r *Tim) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Tim) ProposeChannel(req client.ChannelProposal) (*paymentChannel, error)
- func (r *Tim) RequireNoError(err error)
- func (r *Tim) RequireNoErrorf(err error, msg string, args ...interface{})
- func (r *Tim) RequireTrue(b bool)
- func (r *Tim) RequireTruef(b bool, msg string, args ...interface{})
- func (r *Tim) SetStages(st Stages)
- func (r *Tim) SubChannelProposal(rng io.Reader, cfg ExecConfig, parent *client.Channel, ...) *client.SubChannelProposalMsg
- func (r *Tim) UpdateHandler() *roleUpdateHandler
- type VirtualChannelBalances
- type VirtualChannelSetup
- type Watcher
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
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
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
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.
Types ¶
type Alice ¶
type Alice struct {
Proposer
}
Alice is a Proposer. She proposes the new channel.
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
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
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) 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 (*Alice) RequireTrue ¶ added in v0.10.0
func (r *Alice) RequireTrue(b bool)
func (*Alice) RequireTruef ¶ added in v0.10.0
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
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
func (c *BaseExecConfig) App() client.ProposalOpts
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 (*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) GoHandle ¶ added in v0.3.0
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
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) 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 (*Bob) RequireTrue ¶ added in v0.10.0
func (r *Bob) RequireTrue(b bool)
func (*Bob) RequireTruef ¶ added in v0.10.0
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 (*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
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
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) 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 (*Carol) RequireTrue ¶ added in v0.10.0
func (r *Carol) RequireTrue(b bool)
func (*Carol) RequireTruef ¶ added in v0.10.0
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 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
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
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) 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 (*DisputeSusie) RequireTrue ¶ added in v0.10.0
func (r *DisputeSusie) RequireTrue(b bool)
func (*DisputeSusie) RequireTruef ¶ added in v0.10.0
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
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
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) 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 (*DisputeTim) RequireTrue ¶ added in v0.10.0
func (r *DisputeTim) RequireTrue(b bool)
func (*DisputeTim) RequireTruef ¶ added in v0.10.0
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
func (m FailingFunder) Fund(ctx context.Context, req channel.FundingReq) error
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
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
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
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) 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 (*Mallory) RequireTrue ¶ added in v0.10.0
func (r *Mallory) RequireTrue(b bool)
func (*Mallory) RequireTruef ¶ added in v0.10.0
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
Balance returns the balance for the participant and asset.
func (*MockBackend) Fund ¶ added in v0.7.0
func (b *MockBackend) Fund(ctx context.Context, req channel.FundingReq, acc wallet.Address) error
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
func (b *MockBackend) Subscribe(ctx context.Context, chID channel.ID) (channel.AdjudicatorSubscription, error)
Subscribe creates an event subscription.
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.
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
func (s *MockSubscription) Next() channel.AdjudicatorEvent
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
Paul is a test client role. He proposes the new channel.
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
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
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) 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 (*Paul) RequireTrue ¶ added in v0.10.0
func (r *Paul) RequireTrue(b bool)
func (*Paul) RequireTruef ¶ added in v0.10.0
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
Paula is a test client role. She proposes the new channel.
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
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
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) 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 (*Paula) RequireTrue ¶ added in v0.10.0
func (r *Paula) RequireTrue(b bool)
func (*Paula) RequireTruef ¶ added in v0.10.0
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 (*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
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) 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
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
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) 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 (*Proposer) RequireTrue ¶ added in v0.10.0
func (r *Proposer) RequireTrue(b bool)
func (*Proposer) RequireTruef ¶ added in v0.10.0
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
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) 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
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
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) 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 (*Responder) RequireTrue ¶ added in v0.10.0
func (r *Responder) RequireTrue(b bool)
func (*Responder) RequireTruef ¶ added in v0.10.0
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
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 Susie ¶ added in v0.5.0
type Susie struct {
Proposer
}
Susie is a Proposer. She proposes the new channel.
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
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
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) 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 (*Susie) RequireTrue ¶ added in v0.10.0
func (r *Susie) RequireTrue(b bool)
func (*Susie) RequireTruef ¶ added in v0.10.0
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 (*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
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
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) 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 (*Tim) RequireTrue ¶ added in v0.10.0
func (r *Tim) RequireTrue(b bool)
func (*Tim) RequireTruef ¶ added in v0.10.0
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
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.
Source Files ¶
- alice.go
- backend.go
- bob.go
- carol.go
- channel.go
- doc.go
- fund.go
- handler.go
- mallory.go
- multiledger.go
- multiledger_dispute.go
- multiledger_happy.go
- persistence.go
- progression.go
- proposalmsgs.go
- proposer.go
- randomproposal.go
- responder.go
- role.go
- subchannel.go
- subchannel_dispute.go
- syncmsgs.go
- updatemsgs.go
- virtualchannel.go