Documentation ¶
Index ¶
- Variables
- func DnHeight(v uint64) dnHeightOnPart
- func MajorBlock(v uint64) majorHeightOnPart
- func QueryAccountAs[T protocol.Account](h *Harness, scope *url.URL) T
- func Recordings(tb testing.TB) simulator.RecordingFunc
- func Sig(id *url.TxID) sigCond
- func Txn(id *url.TxID) txnCond
- type BlockStep
- type Condition
- type EnvelopeBuilder
- type Harness
- func (h *Harness) BuildAndSubmit(b EnvelopeBuilder) []*protocol.TransactionStatus
- func (h *Harness) BuildAndSubmitSuccessfully(b EnvelopeBuilder) []*protocol.TransactionStatus
- func (h *Harness) BuildAndSubmitTxn(b EnvelopeBuilder) *protocol.TransactionStatus
- func (h *Harness) BuildAndSubmitTxnSuccessfully(b EnvelopeBuilder) *protocol.TransactionStatus
- func (h *Harness) Network() api.NetworkService
- func (h *Harness) NetworkStatus(opts api.NetworkStatusOptions) *api.NetworkStatus
- func (h *Harness) Query() api.Querier2
- func (h *Harness) QueryAccount(scope *url.URL, query *api.DefaultQuery) *api.AccountRecord
- func (h *Harness) QueryAccountAs(scope *url.URL, query *api.DefaultQuery, target any) *api.AccountRecord
- func (h *Harness) QueryAccountChains(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainRecord]
- func (h *Harness) QueryChain(scope *url.URL, query *api.ChainQuery) *api.ChainRecord
- func (h *Harness) QueryChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
- func (h *Harness) QueryChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[api.Record]
- func (h *Harness) QueryDataEntries(scope *url.URL, query *api.DataQuery) ...
- func (h *Harness) QueryDataEntry(scope *url.URL, query *api.DataQuery) *api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]
- func (h *Harness) QueryDirectory(scope *url.URL, query *api.DirectoryQuery) *api.RecordRange[*api.AccountRecord]
- func (h *Harness) QueryDirectoryUrls(scope *url.URL, query *api.DirectoryQuery) *api.RecordRange[*api.UrlRecord]
- func (h *Harness) QueryIndexChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.IndexEntryRecord]]
- func (h *Harness) QueryIndexChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.IndexEntryRecord]
- func (h *Harness) QueryMainChainEntries(scope *url.URL, query *api.ChainQuery) ...
- func (h *Harness) QueryMainChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]
- func (h *Harness) QueryMajorBlock(scope *url.URL, query *api.BlockQuery) *api.MajorBlockRecord
- func (h *Harness) QueryMajorBlocks(scope *url.URL, query *api.BlockQuery) *api.RecordRange[*api.MajorBlockRecord]
- func (h *Harness) QueryMessage(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[messaging.Message]
- func (h *Harness) QueryMinorBlock(scope *url.URL, query *api.BlockQuery) *api.MinorBlockRecord
- func (h *Harness) QueryMinorBlocks(scope *url.URL, query *api.BlockQuery) *api.RecordRange[*api.MinorBlockRecord]
- func (h *Harness) QueryPending(scope *url.URL, query *api.PendingQuery) *api.RecordRange[*api.MessageRecord[*messaging.TransactionMessage]]
- func (h *Harness) QueryPendingIds(scope *url.URL, query *api.PendingQuery) *api.RecordRange[*api.TxIDRecord]
- func (h *Harness) QuerySignature(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[*messaging.SignatureMessage]
- func (h *Harness) QuerySignatureChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.MessageRecord[messaging.Message]]]
- func (h *Harness) QuerySignatureChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.MessageRecord[messaging.Message]]
- func (h *Harness) QueryTransaction(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[*messaging.TransactionMessage]
- func (h *Harness) QueryTransactionChains(scope *url.TxID, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
- func (h *Harness) SearchForAnchor(scope *url.URL, search *api.AnchorSearchQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
- func (h *Harness) SearchForDelegate(scope *url.URL, search *api.DelegateSearchQuery) *api.RecordRange[*api.KeyRecord]
- func (h *Harness) SearchForMessage(ctx context.Context, hash [32]byte) *api.RecordRange[*api.TxIDRecord]
- func (h *Harness) SearchForPublicKey(scope *url.URL, search *api.PublicKeySearchQuery) *api.RecordRange[*api.KeyRecord]
- func (h *Harness) SearchForPublicKeyHash(scope *url.URL, search *api.PublicKeyHashSearchQuery) *api.RecordRange[*api.KeyRecord]
- func (h *Harness) Step()
- func (h *Harness) StepN(n int)
- func (h *Harness) StepUntil(conditions ...Condition)
- func (h *Harness) StepUntilN(n int, conditions ...Condition)
- func (h *Harness) Submit(envelope *messaging.Envelope) []*protocol.TransactionStatus
- func (h *Harness) SubmitSuccessfully(envelope *messaging.Envelope) []*protocol.TransactionStatus
- func (h *Harness) SubmitTxn(envelope *messaging.Envelope) *protocol.TransactionStatus
- func (h *Harness) SubmitTxnSuccessfully(envelope *messaging.Envelope) *protocol.TransactionStatus
- func (h *Harness) Verify(conditions ...Condition)
- type Services
- type Sim
- func (s *Sim) Database(partition string) database.Updater
- func (s *Sim) DatabaseFor(account *url.URL) database.Updater
- func (s *Sim) Partitions() []*protocol.PartitionInfo
- func (s *Sim) Router() *simulator.Router
- func (s *Sim) SetBlockHook(partition string, fn simulator.BlockHookFunc)
- func (s *Sim) SetBlockHookFor(account *url.URL, fn simulator.BlockHookFunc)
- func (s *Sim) SetNodeBlockHook(partition string, fn simulator.NodeBlockHookFunc)
- func (s *Sim) SetNodeBlockHookFor(account *url.URL, fn simulator.NodeBlockHookFunc)
- func (s *Sim) SetRoute(account *url.URL, partition string)
- func (s *Sim) SetSubmitHook(partition string, fn simulator.SubmitHookFunc)
- func (s *Sim) SetSubmitHookFor(account *url.URL, fn simulator.SubmitHookFunc)
- func (s *Sim) SignWithNode(partition string, i int) signing.Signer
- func (s *Sim) SubmitTo(partition string, envelope *messaging.Envelope) ([]*protocol.TransactionStatus, error)
- type Stepper
- type TimeStep
- type True
Constants ¶
This section is empty.
Variables ¶
var GenesisTime = time.Date(2022, 7, 1, 0, 0, 0, 0, time.UTC)
GenesisTime is 2022-7-1 0:00 UTC.
Functions ¶
func MajorBlock ¶ added in v1.2.0
func MajorBlock(v uint64) majorHeightOnPart
func QueryAccountAs ¶
QueryAccountAs calls Harness.QueryAccountAs with a new T and returns that value.
func Recordings ¶ added in v1.2.0
func Recordings(tb testing.TB) simulator.RecordingFunc
Types ¶
type BlockStep ¶
type BlockStep <-chan api.Event
BlockStep implements Stepper by waiting for a block event.
type Condition ¶
A Condition is a function that is used by Harness.StepUntil to wait until some condition is met.
type EnvelopeBuilder ¶
EnvelopeBuilder builds an envelope.
type Harness ¶
type Harness struct { TB testing.TB VerboseConditions bool // contains filtered or unexported fields }
Harness is a test harness.
func (*Harness) BuildAndSubmit ¶
func (h *Harness) BuildAndSubmit(b EnvelopeBuilder) []*protocol.TransactionStatus
BuildAndSubmit builds and submits the envelope.
func (*Harness) BuildAndSubmitSuccessfully ¶
func (h *Harness) BuildAndSubmitSuccessfully(b EnvelopeBuilder) []*protocol.TransactionStatus
BuildAndSubmitSuccessfully builds and submits the envelope and asserts that all transactions and signatures succeeded.
func (*Harness) BuildAndSubmitTxn ¶
func (h *Harness) BuildAndSubmitTxn(b EnvelopeBuilder) *protocol.TransactionStatus
BuildAndSubmitTxn builds and submits a single transaction.
func (*Harness) BuildAndSubmitTxnSuccessfully ¶
func (h *Harness) BuildAndSubmitTxnSuccessfully(b EnvelopeBuilder) *protocol.TransactionStatus
BuildAndSubmitTxnSuccessfully builds and submits a single transaction and asserts that it and its signatures succeeded.
func (*Harness) Network ¶
func (h *Harness) Network() api.NetworkService
Network returns the Harness's service as an api.NetworkService.
func (*Harness) NetworkStatus ¶
func (h *Harness) NetworkStatus(opts api.NetworkStatusOptions) *api.NetworkStatus
NetworkStatus calls the Harness's service, failing if the call returns an error.
func (*Harness) Query ¶
func (h *Harness) Query() api.Querier2
Query returns the Harness's service as an api.Querier2.
func (*Harness) QueryAccount ¶
QueryAccount queries the Harness's service, passing the given arguments. QueryAccount fails if Query returns an error. See api.Querier2.QueryAccount.
func (*Harness) QueryAccountAs ¶
func (h *Harness) QueryAccountAs(scope *url.URL, query *api.DefaultQuery, target any) *api.AccountRecord
QueryAccountAs queries the Harness's service, passing the given arguments. QueryAccountAs fails if Query returns an error. See api.Querier2.QueryAccountAs.
func (*Harness) QueryAccountChains ¶
func (h *Harness) QueryAccountChains(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainRecord]
QueryAccountChains queries the Harness's service, passing the given arguments. QueryAccountChains fails if Query returns an error. See api.Querier2.QueryAccountChains.
func (*Harness) QueryChain ¶
QueryChain queries the Harness's service, passing the given arguments. QueryChain fails if Query returns an error. See api.Querier2.QueryChain.
func (*Harness) QueryChainEntries ¶
func (h *Harness) QueryChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
QueryChainEntries queries the Harness's service, passing the given arguments. QueryChainEntries fails if Query returns an error. See api.Querier2.QueryChainEntries.
func (*Harness) QueryChainEntry ¶
func (h *Harness) QueryChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[api.Record]
QueryChainEntry queries the Harness's service, passing the given arguments. QueryChainEntry fails if Query returns an error. See api.Querier2.QueryChainEntry.
func (*Harness) QueryDataEntries ¶
func (h *Harness) QueryDataEntries(scope *url.URL, query *api.DataQuery) *api.RecordRange[*api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]]
QueryDataEntries queries the Harness's service, passing the given arguments. QueryDataEntries fails if Query returns an error. See api.Querier2.QueryDataEntries.
func (*Harness) QueryDataEntry ¶
func (h *Harness) QueryDataEntry(scope *url.URL, query *api.DataQuery) *api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]
QueryDataEntry queries the Harness's service, passing the given arguments. QueryDataEntry fails if Query returns an error. See api.Querier2.QueryDataEntry.
func (*Harness) QueryDirectory ¶
func (h *Harness) QueryDirectory(scope *url.URL, query *api.DirectoryQuery) *api.RecordRange[*api.AccountRecord]
QueryDirectory queries the Harness's service, passing the given arguments. QueryDirectory fails if Query returns an error. See api.Querier2.QueryDirectory.
func (*Harness) QueryDirectoryUrls ¶
func (h *Harness) QueryDirectoryUrls(scope *url.URL, query *api.DirectoryQuery) *api.RecordRange[*api.UrlRecord]
QueryDirectoryUrls queries the Harness's service, passing the given arguments. QueryDirectoryUrls fails if Query returns an error. See api.Querier2.QueryDirectoryUrls.
func (*Harness) QueryIndexChainEntries ¶
func (h *Harness) QueryIndexChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.IndexEntryRecord]]
QueryIndexChainEntries queries the Harness's service, passing the given arguments. QueryIndexChainEntries fails if Query returns an error. See api.Querier2.QueryIndexChainEntries.
func (*Harness) QueryIndexChainEntry ¶
func (h *Harness) QueryIndexChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.IndexEntryRecord]
QueryIndexChainEntry queries the Harness's service, passing the given arguments. QueryIndexChainEntry fails if Query returns an error. See api.Querier2.QueryIndexChainEntry.
func (*Harness) QueryMainChainEntries ¶
func (h *Harness) QueryMainChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]]
QueryMainChainEntries queries the Harness's service, passing the given arguments. QueryMainChainEntries fails if Query returns an error. See api.Querier2.QueryMainChainEntries.
func (*Harness) QueryMainChainEntry ¶
func (h *Harness) QueryMainChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.MessageRecord[*messaging.TransactionMessage]]
QueryMainChainEntry queries the Harness's service, passing the given arguments. QueryMainChainEntry fails if Query returns an error. See api.Querier2.QueryMainChainEntry.
func (*Harness) QueryMajorBlock ¶
QueryMajorBlock queries the Harness's service, passing the given arguments. QueryMajorBlock fails if Query returns an error. See api.Querier2.QueryMajorBlock.
func (*Harness) QueryMajorBlocks ¶
func (h *Harness) QueryMajorBlocks(scope *url.URL, query *api.BlockQuery) *api.RecordRange[*api.MajorBlockRecord]
QueryMajorBlocks queries the Harness's service, passing the given arguments. QueryMajorBlocks fails if Query returns an error. See api.Querier2.QueryMajorBlocks.
func (*Harness) QueryMessage ¶
func (h *Harness) QueryMessage(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[messaging.Message]
QueryMessage queries the Harness's service, passing the given arguments. QueryMessage fails if Query returns an error. See api.Querier2.QueryMessage.
func (*Harness) QueryMinorBlock ¶
QueryMinorBlock queries the Harness's service, passing the given arguments. QueryMinorBlock fails if Query returns an error. See api.Querier2.QueryMinorBlock.
func (*Harness) QueryMinorBlocks ¶
func (h *Harness) QueryMinorBlocks(scope *url.URL, query *api.BlockQuery) *api.RecordRange[*api.MinorBlockRecord]
QueryMinorBlocks queries the Harness's service, passing the given arguments. QueryMinorBlocks fails if Query returns an error. See api.Querier2.QueryMinorBlocks.
func (*Harness) QueryPending ¶
func (h *Harness) QueryPending(scope *url.URL, query *api.PendingQuery) *api.RecordRange[*api.MessageRecord[*messaging.TransactionMessage]]
QueryPending queries the Harness's service, passing the given arguments. QueryPending fails if Query returns an error. See api.Querier2.QueryPending.
func (*Harness) QueryPendingIds ¶
func (h *Harness) QueryPendingIds(scope *url.URL, query *api.PendingQuery) *api.RecordRange[*api.TxIDRecord]
QueryPendingIds queries the Harness's service, passing the given arguments. QueryPendingIds fails if Query returns an error. See api.Querier2.QueryPendingIds.
func (*Harness) QuerySignature ¶
func (h *Harness) QuerySignature(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[*messaging.SignatureMessage]
QuerySignature queries the Harness's service, passing the given arguments. QuerySignature fails if Query returns an error. See api.Querier2.QuerySignature.
func (*Harness) QuerySignatureChainEntries ¶
func (h *Harness) QuerySignatureChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.MessageRecord[messaging.Message]]]
QuerySignatureChainEntries queries the Harness's service, passing the given arguments. QuerySignatureChainEntries fails if Query returns an error. See api.Querier2.QuerySignatureChainEntries.
func (*Harness) QuerySignatureChainEntry ¶
func (h *Harness) QuerySignatureChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.MessageRecord[messaging.Message]]
QuerySignatureChainEntry queries the Harness's service, passing the given arguments. QuerySignatureChainEntry fails if Query returns an error. See api.Querier2.QuerySignatureChainEntry.
func (*Harness) QueryTransaction ¶
func (h *Harness) QueryTransaction(txid *url.TxID, query *api.DefaultQuery) *api.MessageRecord[*messaging.TransactionMessage]
QueryTransaction queries the Harness's service, passing the given arguments. QueryTransaction fails if Query returns an error. See api.Querier2.QueryTransaction.
func (*Harness) QueryTransactionChains ¶
func (h *Harness) QueryTransactionChains(scope *url.TxID, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
QueryTransactionChains queries the Harness's service, passing the given arguments. QueryTransactionChains fails if Query returns an error. See api.Querier2.QueryTransactionChains.
func (*Harness) SearchForAnchor ¶
func (h *Harness) SearchForAnchor(scope *url.URL, search *api.AnchorSearchQuery) *api.RecordRange[*api.ChainEntryRecord[api.Record]]
SearchForAnchor queries the Harness's service, passing the given arguments. SearchForAnchor fails if Query returns an error. See api.Querier2.SearchForAnchor.
func (*Harness) SearchForDelegate ¶
func (h *Harness) SearchForDelegate(scope *url.URL, search *api.DelegateSearchQuery) *api.RecordRange[*api.KeyRecord]
SearchForDelegate queries the Harness's service, passing the given arguments. SearchForDelegate fails if Query returns an error. See api.Querier2.SearchForDelegate.
func (*Harness) SearchForMessage ¶
func (h *Harness) SearchForMessage(ctx context.Context, hash [32]byte) *api.RecordRange[*api.TxIDRecord]
SearchForTransactionHash queries the Harness's service, passing the given arguments. SearchForTransactionHash fails if Query returns an error. See api.Querier2.SearchForTransactionHash.
func (*Harness) SearchForPublicKey ¶
func (h *Harness) SearchForPublicKey(scope *url.URL, search *api.PublicKeySearchQuery) *api.RecordRange[*api.KeyRecord]
SearchForPublicKey queries the Harness's service, passing the given arguments. SearchForPublicKey fails if Query returns an error. See api.Querier2.SearchForPublicKey.
func (*Harness) SearchForPublicKeyHash ¶
func (h *Harness) SearchForPublicKeyHash(scope *url.URL, search *api.PublicKeyHashSearchQuery) *api.RecordRange[*api.KeyRecord]
SearchForPublicKeyHash queries the Harness's service, passing the given arguments. SearchForPublicKeyHash fails if Query returns an error. See api.Querier2.SearchForPublicKeyHash.
func (*Harness) StepUntil ¶
StepUntil calls the stepper until all conditions are satisfied. StepUntil fails if the conditions are not met within 50 steps.
func (*Harness) StepUntilN ¶ added in v1.1.1
StepUntilN calls the stepper until all conditions are satisfied. StepUntilN fails if the conditions are not met within N steps.
func (*Harness) Submit ¶
func (h *Harness) Submit(envelope *messaging.Envelope) []*protocol.TransactionStatus
Submit submits the envelope.
func (*Harness) SubmitSuccessfully ¶
func (h *Harness) SubmitSuccessfully(envelope *messaging.Envelope) []*protocol.TransactionStatus
SubmitSuccessfully submits the envelope and asserts that all transactions and signatures succeeded.
func (*Harness) SubmitTxn ¶
func (h *Harness) SubmitTxn(envelope *messaging.Envelope) *protocol.TransactionStatus
SubmitTxn submits a single transaction.
func (*Harness) SubmitTxnSuccessfully ¶
func (h *Harness) SubmitTxnSuccessfully(envelope *messaging.Envelope) *protocol.TransactionStatus
SubmitTxnSuccessfully submits a single transaction and asserts that it and its signatures succeeded.
type Services ¶
type Services interface { api.Querier api.Submitter api.NetworkService }
Services defines the services required by the harness.
type Sim ¶
Sim is a Harness with some extra simulator-specific features.
func NewSim ¶
func NewSim(tb testing.TB, database simulator.OpenDatabaseFunc, init *accumulated.NetworkInit, snapshot simulator.SnapshotFunc) *Sim
NewSim creates a simulator with the given database, network initialization, and snapshot function and calls NewSimWith.
func NewSimWith ¶
NewSimWith creates a Harness for the given simulator instance and wraps it as a Sim.
func (*Sim) DatabaseFor ¶
DatabaseFor calls Simulator.DatabaseFor.
func (*Sim) Partitions ¶
func (s *Sim) Partitions() []*protocol.PartitionInfo
Partitions calls Simulator.Partitions.
func (*Sim) SetBlockHook ¶
func (s *Sim) SetBlockHook(partition string, fn simulator.BlockHookFunc)
SetBlockHook calls Simulator.SetBlockHook.
func (*Sim) SetBlockHookFor ¶
func (s *Sim) SetBlockHookFor(account *url.URL, fn simulator.BlockHookFunc)
SetBlockHookFor calls Simulator.SetBlockHookFor.
func (*Sim) SetNodeBlockHook ¶ added in v1.1.1
func (s *Sim) SetNodeBlockHook(partition string, fn simulator.NodeBlockHookFunc)
SetNodeBlockHook calls Simulator.SetNodeBlockHook.
func (*Sim) SetNodeBlockHookFor ¶ added in v1.1.1
func (s *Sim) SetNodeBlockHookFor(account *url.URL, fn simulator.NodeBlockHookFunc)
SetNodeBlockHookFor calls Simulator.SetNodeBlockHookFor.
func (*Sim) SetSubmitHook ¶
func (s *Sim) SetSubmitHook(partition string, fn simulator.SubmitHookFunc)
SetSubmitHook calls Simulator.SetSubmitHook.
func (*Sim) SetSubmitHookFor ¶
func (s *Sim) SetSubmitHookFor(account *url.URL, fn simulator.SubmitHookFunc)
SetSubmitHookFor calls Simulator.SetSubmitHookFor.
func (*Sim) SignWithNode ¶
SignWithNode calls Simulator.SignWithNode.
type Stepper ¶
type Stepper interface {
Step() error
}
Stepper steps the simulation or waits for a block to complete.