Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Funded = setupModifier(func(s *Setup) { chID := s.State.ID for i, part := range s.Parts { _ = s.Adj.Mint(s.IDs[i], s.State.Balances[i]) if err := s.Adj.Deposit(s.IDs[i], chID, part, s.State.Balances[i]); err != nil { panic(fmt.Sprintf("Setup: error funding participant[%d]: %v", i, err)) } } })
Funded performs minting and deposit for all participants. Therefore, the state channel is prefunded.
var WithFinalState = setupModifier(func(s *Setup) { s.State.IsFinal = true })
WithFinalState allows to set the channel final flag to true.
Functions ¶
func RandomParams ¶
RandomParams returns random channel parameters for testing.
func RandomState ¶
RandomState returns a random channel state for testing.
Types ¶
type Setup ¶
type Setup struct { IDs []adj.AccountID Parts []wallet.Address Accs []wallet.Account Params *adj.Params State *adj.State Ledger *TestLedger Adj *adj.Adjudicator Timeout adj.Timestamp }
Setup provides necessary elements for testing.
func NewSetup ¶
func NewSetup(rng *rand.Rand, opts ...SetupOption) *Setup
NewSetup generates a new test setup. Each setup is created with new random accounts and an initial channel state.
func (*Setup) SignedChannel ¶
func (s *Setup) SignedChannel() *adj.SignedChannel
SignedChannel returns a signed channel based on the current channel state (Params, State, Accs) of the Setup.
type SetupOption ¶
type SetupOption interface {
// contains filtered or unexported methods
}
SetupOption extends the Setup constructor.
func WithAccounts ¶
func WithAccounts(accs ...wallet.Account) SetupOption
WithAccounts allows setting own Accounts instead of using random ones.
func WithChannelBalances ¶
func WithChannelBalances(bals ...channel.Bal) SetupOption
WithChannelBalances allows giving own balances instead of the default ones.
func WithMintedTokens ¶
func WithMintedTokens(fund ...*big.Int) SetupOption
WithMintedTokens mints for all participants the given amount of tokens at start.
func WithVersion ¶
func WithVersion(v uint64) SetupOption
WithVersion allows to set the state version.
type TestLedger ¶
TestLedger is a MemLedger with a controllable clock. The timestamp returned by Now stays constant until it is advanced with AdvanceNow. The initial value of now is set at creation to MemLedger.Now().
func NewTestLedger ¶
func NewTestLedger() *TestLedger
NewTestLedger creates a test ledger with a controllable clock.
func (*TestLedger) AdvanceNow ¶
func (l *TestLedger) AdvanceNow(duration uint64)
AdvanceNow adds the given duration onto the current time of the TestLedger.
func (*TestLedger) Now ¶
func (l *TestLedger) Now() adj.Timestamp
Now returns the current time on the TestLedger.