Documentation ¶
Overview ¶
Package test contains helpers for testing the client
Index ¶
- type Alice
- func (r *Alice) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Alice) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Alice) EnableStages() Stages
- func (r *Alice) Execute(cfg ExecConfig)
- func (r *Alice) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Alice) GoListen(l peer.Listener) (wait func())
- func (r *Alice) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Alice) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Alice) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Alice) SetStages(st Stages)
- func (r *Alice) UpdateHandler() *roleUpdateHandler
- type Bob
- func (r *Bob) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Bob) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Bob) EnableStages() Stages
- func (r *Bob) Execute(cfg ExecConfig)
- func (r *Bob) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Bob) GoListen(l peer.Listener) (wait func())
- func (r *Bob) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Bob) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Bob) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Bob) SetStages(st Stages)
- func (r *Bob) UpdateHandler() *roleUpdateHandler
- type Carol
- func (r *Carol) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Carol) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Carol) EnableStages() Stages
- func (r *Carol) Execute(cfg ExecConfig)
- func (r *Carol) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Carol) GoListen(l peer.Listener) (wait func())
- func (r *Carol) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Carol) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Carol) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Carol) SetStages(st Stages)
- func (r *Carol) UpdateHandler() *roleUpdateHandler
- type ConnHub
- type ExecConfig
- type Executer
- type Mallory
- func (r *Mallory) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Mallory) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Mallory) EnableStages() Stages
- func (r *Mallory) Execute(cfg ExecConfig)
- func (r *Mallory) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Mallory) GoListen(l peer.Listener) (wait func())
- func (r *Mallory) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Mallory) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Mallory) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Mallory) SetStages(st Stages)
- func (r *Mallory) UpdateHandler() *roleUpdateHandler
- type Petra
- type Proposer
- func (r *Proposer) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Proposer) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Proposer) EnableStages() Stages
- func (r *Proposer) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel))
- func (r *Proposer) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Proposer) GoListen(l peer.Listener) (wait func())
- func (r *Proposer) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Proposer) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Proposer) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Proposer) SetStages(st Stages)
- func (r *Proposer) UpdateHandler() *roleUpdateHandler
- type Responder
- func (r *Responder) AcceptAllPropHandler(rng *rand.Rand) *acceptAllPropHandler
- func (r *Responder) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
- func (r *Responder) EnableStages() Stages
- func (r *Responder) Execute(cfg ExecConfig, exec func(ExecConfig, *paymentChannel))
- func (r *Responder) GoHandle(rng *rand.Rand) (h *acceptAllPropHandler, wait func())
- func (r *Responder) GoListen(l peer.Listener) (wait func())
- func (r *Responder) Idxs(peers [2]peer.Address) (our, their int)
- func (r *Responder) OnNewChannel(callback func(ch *paymentChannel))
- func (r *Responder) ProposeChannel(req *client.ChannelProposal) (*paymentChannel, error)
- func (r *Responder) SetStages(st Stages)
- func (r *Responder) UpdateHandler() *roleUpdateHandler
- type Robert
- type RoleSetup
- type Stages
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alice ¶
type Alice struct {
Proposer
}
Alice is a Proposer. She proposes the new channel.
func (*Alice) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Alice) ChannelProposal ¶ added in v0.3.0
func (r *Alice) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener 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) 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) 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) UpdateHandler ¶ added in v0.3.0
func (r *Alice) UpdateHandler() *roleUpdateHandler
type Bob ¶
type Bob struct {
Responder
}
Bob is a Responder. He accepts an incoming channel proposal.
func (*Bob) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Bob) ChannelProposal ¶ added in v0.3.0
func (r *Bob) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener 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) 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) 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) UpdateHandler ¶ added in v0.3.0
func (r *Bob) UpdateHandler() *roleUpdateHandler
type Carol ¶ added in v0.2.0
type Carol struct {
Responder
}
Carol is a Responder. She accepts an incoming channel proposal.
func (*Carol) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Carol) ChannelProposal ¶ added in v0.3.0
func (r *Carol) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener routine to stop.
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) 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) 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) UpdateHandler ¶ added in v0.3.0
func (r *Carol) UpdateHandler() *roleUpdateHandler
type ConnHub ¶ added in v0.3.0
A ConnHub can be used to create related Listeners and Dialers. This is (almost) fulfilled by the peer/test.ConnHub but in order to be able to use possible other netorking infrastructure for the tests in the future, it is consumed as an interface in the client persistence tests.
type ExecConfig ¶
type ExecConfig struct { PeerAddrs [2]peer.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 NumUpdates [2]int // how many updates each role sends TxAmounts [2]*big.Int // amounts that are to be sent by each role }
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) }
An Executer is a Role that can execute a protocol.
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) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Mallory) ChannelProposal ¶ added in v0.3.0
func (r *Mallory) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener 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) 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) 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) UpdateHandler ¶ added in v0.3.0
func (r *Mallory) 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) Execute ¶ added in v0.3.0
func (r *Petra) Execute(cfg ExecConfig)
Execute executes the Petra protocol.
func (*Petra) NewListener ¶ added in v0.3.0
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 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) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Proposer) ChannelProposal ¶ added in v0.3.0
func (r *Proposer) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener 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) 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) 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) 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) AcceptAllPropHandler ¶ added in v0.3.0
AcceptAllPropHandler returns a ProposalHandler that accepts all requests to this Role. The paymentChannel is saved to the Role's state upon acceptal. The rng is used to generate a new random account for accepting the proposal. Next can be called on the handler to wait for the next incoming proposal.
func (*Responder) ChannelProposal ¶ added in v0.3.0
func (r *Responder) ChannelProposal(rng *rand.Rand, cfg *ExecConfig) *client.ChannelProposal
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))
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) GoListen ¶ added in v0.3.0
GoListen starts the peer listener routine on the current client and returns a wait() function with which it can be waited for the listener 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) 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) 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) 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) Execute ¶ added in v0.3.0
func (r *Robert) Execute(cfg ExecConfig)
Execute executes the Robert protocol.
func (*Robert) NewListener ¶ added in v0.3.0
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 peer.Identity Dialer peer.Dialer Listener peer.Listener Funder channel.Funder Adjudicator channel.Adjudicator Wallet wallettest.Wallet PR persistence.PersistRestorer // Optional PersistRestorer Timeout time.Duration // Timeout waiting for other role, not challenge duration }
RoleSetup contains the injectables for setting up the client.