Documentation
¶
Index ¶
- Variables
- 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 SimContractTx
- type SimTx
- type User
- 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 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 { // AdminUser is the client for the mimir admin account. AdminUser *User // NodeUsers is a slice clients for simulation validator keys. NodeUsers []*User // Users is a slice of clients for simulation user keys. Users []*User }
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 SimContractTx ¶ added in v1.133.0
type SimContractTx struct { Chain common.Chain Contract common.Address ABI abi.ABI Method string Args []interface{} }
SimContractTx is a struct used for simulation contract call transactions.
type User ¶ added in v1.133.0
type User 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 }
User holds a set of chain clients configured with a given private key.
func NewUser ¶ added in v1.133.0
func NewUser(mnemonic string, constructors map[common.Chain]LiteChainClientConstructor) *User
NewUser returns a new client using the private key from the given mnemonic.
func (*User) Acquire ¶ added in v1.133.0
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.
func (*User) Address ¶ added in v1.133.0
Address returns the address of the client for the given chain.
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.