Documentation ¶
Index ¶
- func CheckTx(t TB, db *database.Database, exec *Executor, delivery *chain.Delivery) (protocol.TransactionResult, error)
- func DeliverTx(t TB, exec *Executor, block *Block, delivery *chain.Delivery) (*protocol.TransactionStatus, error)
- func ExecuteBlock(t TB, db *database.Database, exec *Executor, block *Block, ...) ([]*protocol.TransactionStatus, error)
- func GetAccount[T protocol.Account](sim *Simulator, accountUrl *url.URL) T
- func InitFromGenesis(t TB, db *database.Database, exec *Executor)
- func InitFromSnapshot(t TB, db *database.Database, exec *Executor, filename string)
- func NormalizeEnvelope(t TB, envelope *protocol.Envelope) []*chain.Delivery
- func Query(t TB, db *database.Database, exec *Executor, req query.Request, prove bool) interface{}
- func RequireSuccess(t TB, results ...*protocol.TransactionStatus)
- type ExecEntry
- type Simulator
- func (s *Simulator) CreateAccount(account protocol.Account)
- func (s *Simulator) CreateIdentity(identityUrl *url.URL, pubKey ...[]byte)
- func (s *Simulator) CreateKeyBook(bookUrl *url.URL, pubKey ...[]byte)
- func (s *Simulator) CreateKeyPage(bookUrl *url.URL, pubKey ...[]byte)
- func (t Simulator) Errorf(format string, args ...interface{})
- func (s *Simulator) ExecuteBlock(statusChan chan<- *protocol.TransactionStatus)
- func (s *Simulator) ExecuteBlocks(n int)
- func (t Simulator) Fatalf(format string, args ...interface{})
- func (s *Simulator) InitFromGenesis()
- func (s *Simulator) InitFromSnapshot(filename func(string) string)
- func (t Simulator) Logf(format string, args ...interface{})
- func (s *Simulator) MustSubmitAndExecuteBlock(envelopes ...*protocol.Envelope) []*protocol.Envelope
- func (s *Simulator) Query(url *url.URL, req query.Request, prove bool) interface{}
- func (s *Simulator) Router() routing.Router
- func (s *Simulator) SetRouteFor(account *url.URL, subnet string)
- func (s *Simulator) Submit(envelopes ...*protocol.Envelope) ([]*protocol.Envelope, error)
- func (s *Simulator) SubmitAndExecuteBlock(envelopes ...*protocol.Envelope) ([]*protocol.TransactionStatus, error)
- func (s *Simulator) Subnet(id string) *ExecEntry
- func (s *Simulator) SubnetFor(url *url.URL) *ExecEntry
- func (s *Simulator) UpdateAccount(accountUrl *url.URL, fn func(account protocol.Account))
- func (s *Simulator) WaitForTransactionFlow(statusCheck func(*protocol.TransactionStatus) bool, txnHash []byte) ([]*protocol.TransactionStatus, []*protocol.Transaction)
- func (s *Simulator) WaitForTransactions(status func(*protocol.TransactionStatus) bool, envelopes ...*protocol.Envelope) ([]*protocol.TransactionStatus, []*protocol.Transaction)
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteBlock ¶
func GetAccount ¶ added in v1.0.0
func InitFromGenesis ¶
func InitFromSnapshot ¶ added in v1.0.0
func NormalizeEnvelope ¶
func RequireSuccess ¶
func RequireSuccess(t TB, results ...*protocol.TransactionStatus)
Types ¶
type ExecEntry ¶
type ExecEntry struct { Database *database.Database Executor *block.Executor API *client.Client // SubmitHook can be used to control how envelopes are submitted to the // subnet. It is not safe to change SubmitHook concurrently with calls to // Submit. SubmitHook func([]*protocol.Envelope) []*protocol.Envelope // contains filtered or unexported fields }
func (*ExecEntry) Submit ¶
Submit adds the envelopes to the next block's queue.
By adding transactions to the next block and swaping queues when a block is executed, we roughly simulate the process Tendermint uses to build blocks.
func (*ExecEntry) TakeSubmitted ¶
TakeSubmitted returns the envelopes for the current block.
type Simulator ¶
type Simulator struct { Logger log.Logger Subnets []config.Subnet Executors map[string]*ExecEntry // contains filtered or unexported fields }
func (*Simulator) CreateAccount ¶
func (*Simulator) CreateIdentity ¶
func (*Simulator) CreateKeyBook ¶
func (*Simulator) CreateKeyPage ¶
func (*Simulator) ExecuteBlock ¶
func (s *Simulator) ExecuteBlock(statusChan chan<- *protocol.TransactionStatus)
ExecuteBlock executes a block after submitting envelopes. If a status channel is provided, statuses will be sent to the channel as transactions are executed. Once the block is complete, the status channel will be closed (if provided).
func (*Simulator) ExecuteBlocks ¶
ExecuteBlocks executes a number of blocks. This is useful for things like waiting for a block to be anchored.
func (*Simulator) InitFromGenesis ¶ added in v1.0.0
func (s *Simulator) InitFromGenesis()
func (*Simulator) InitFromSnapshot ¶ added in v1.0.0
func (*Simulator) MustSubmitAndExecuteBlock ¶
MustSubmitAndExecuteBlock executes a block with the envelopes and fails the test if any envelope fails.
func (*Simulator) SubmitAndExecuteBlock ¶
func (s *Simulator) SubmitAndExecuteBlock(envelopes ...*protocol.Envelope) ([]*protocol.TransactionStatus, error)
SubmitAndExecuteBlock executes a block with the envelopes.
func (*Simulator) UpdateAccount ¶
func (*Simulator) WaitForTransactionFlow ¶
func (s *Simulator) WaitForTransactionFlow(statusCheck func(*protocol.TransactionStatus) bool, txnHash []byte) ([]*protocol.TransactionStatus, []*protocol.Transaction)
func (*Simulator) WaitForTransactions ¶
func (s *Simulator) WaitForTransactions(status func(*protocol.TransactionStatus) bool, envelopes ...*protocol.Envelope) ([]*protocol.TransactionStatus, []*protocol.Transaction)