Documentation ¶
Index ¶
- Variables
- type Account
- type Actor
- func (a *Actor) Append(b *Actor)
- func (a *Actor) Execute(c *OpConfig) (err error)
- func (a *Actor) Finished() bool
- func (a *Actor) InitRoot()
- func (a *Actor) Log() *zerolog.Logger
- func (a *Actor) Parents() map[*Actor]bool
- func (a *Actor) SetLogger(l zerolog.Logger)
- func (a *Actor) Start()
- func (a *Actor) Started() bool
- func (a *Actor) WalkDepthFirst(f func(*Actor) bool) (cont bool)
- type LiteChainClient
- type LiteChainClientConstructor
- type Op
- type OpConfig
- type OpResult
- type SimTx
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("timeout")
ErrTimeout is returned when an actor times out.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // Thorchain is the thorchain client for the account. Thorchain thorclient.ThorchainBridge // ChainClients is a map of chain to the corresponding client for the account. ChainClients map[common.Chain]LiteChainClient // contains filtered or unexported fields }
Account holds a set of chain clients configured with a given private key.
func NewAccount ¶
func NewAccount(mnemonic string, constructors map[common.Chain]LiteChainClientConstructor) *Account
NewAccount returns a new client using the private key from the given mnemonic.
func (*Account) Acquire ¶
Acquire will attempt to acquire the lock. If the lock is already acquired, it will return false. If true is returned, the caller has locked and must release when done.
type Actor ¶
type Actor struct { // Name is the name of the actor. Name string // Timeout is the maximum amount of time the actor is allowed to execute. Timeout time.Duration // Interval is the amount of time to wait between operations. Interval time.Duration // Ops is the set of operations to execute. Ops []Op `json:"-"` // Children is the set of children to execute after the operations have completed. Children map[*Actor]bool `json:"-"` // contains filtered or unexported fields }
Actor is a node in the actor tree, which is processed as a DAG. Each actor has a set of operations to execute and a set of children. The actor will execute each operation in order until the operation returns Continue = false. If the operation returns Finish = true, the actor will stop executing and return the error. Once an actor has finished, the children of the actor will be executed. Actors may be appended to other actors, which results in the final descendants of the actor being parents of the appended actor - blocking the execution of the appended actor until all parents have completed, allowing for "fan in" of the execution DAG.
func (*Actor) Append ¶
Append will append the provided actor - all descendants of the actor will be parents of the provided actor (the provided actor and descendants will not be executed until all parents have completed).
type LiteChainClient ¶
type LiteChainClient interface { // GetAccount returns the account for the given public key. If the key is nil, it // returns the account for the client's configured key. GetAccount(_ *common.PubKey) (*common.Account, error) // SignTx returns the signed transaction. SignTx(tx SimTx) ([]byte, error) // BroadcastTx broadcasts the transaction and returns the hash. BroadcastTx([]byte) (string, error) }
LiteChainClient is a subset of the ChainClient interface used for simulation tests.
type LiteChainClientConstructor ¶
type LiteChainClientConstructor func(_ common.Chain, _ *thorclient.Keys) (LiteChainClient, error)
LiteChainClientConstructor is a function that creates a new LiteChainClient.
type OpConfig ¶
type OpConfig struct { // AdminAccount is the client for the mimir admin account. AdminAccount *Account // NodeAccounts is a slice clients for simulation validator keys. NodeAccounts []*Account // UserAccounts is a slice of clients for simulation user keys. UserAccounts []*Account }
OpConfig is the configuration passed to each operation during execution.
type OpResult ¶
type OpResult struct { // Continue indicates that actor should continue to the next operation. Continue bool // Finish indicates that the actor should stop executing and return the error. Finish bool // Error is the error returned by the operation. Error error }
OpResult is the result of an operation.
type Watcher ¶
type Watcher struct { // Name is the name of the watcher. Name string // Interval is the interval at which the watcher will be executed. Interval time.Duration // Fn is the function to execute. Fn func(config *OpConfig) error }
Watcher wraps a function that will be executed on some interval in the background for the duration of the simulation. The function is passed the same OpConfig as the operations in the actor tree so it is able to access the clients and accounts used by the actors. If it returns an error or panics, the simulation will be aborted.