harness

package
v1.1.0-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenesisTime = time.Date(2022, 7, 1, 0, 0, 0, 0, time.UTC)

GenesisTime is 2022-7-1 0:00 UTC.

Functions

func QueryAccountAs

func QueryAccountAs[T protocol.Account](h *Harness, scope *url.URL) T

QueryAccountAs calls Harness.QueryAccountAs with a new T and returns that value.

func Txn

func Txn(id *url.TxID) *condTxn

Txn defines a condition on a transaction.

Types

type BlockStep

type BlockStep <-chan api.Event

BlockStep implements Stepper by waiting for a block event.

func (BlockStep) Step

func (s BlockStep) Step() error

Step processes events until there is an error or a block event.

type Condition

type Condition func(*Harness) bool

A Condition is a function that is used by Harness.StepUntil to wait until some condition is met.

type EnvelopeBuilder

type EnvelopeBuilder interface {
	Done() (*protocol.Envelope, error)
}

EnvelopeBuilder builds an envelope.

type Harness

type Harness struct {
	TB testing.TB
	// contains filtered or unexported fields
}

Harness is a test harness.

func New

func New(tb testing.TB, services Services, stepper Stepper) *Harness

New returns a new Harness with the given services and stepper.

func (*Harness) BuildAndSubmit

func (h *Harness) BuildAndSubmit(b EnvelopeBuilder) *protocol.TransactionStatus

BuildAndSubmit calls the envelope builder and submits the envelope.

func (*Harness) BuildAndSubmitSuccessfully

func (h *Harness) BuildAndSubmitSuccessfully(b EnvelopeBuilder) *protocol.TransactionStatus

BuildAndSubmitSuccessfully calls the envelope builder and submits the envelope. BuildAndSubmitSuccessfully fails if the transaction failed.

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

func (h *Harness) QueryAccount(scope *url.URL, query *api.DefaultQuery) *api.AccountRecord

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) QueryChain

func (h *Harness) QueryChain(scope *url.URL, query *api.ChainQuery) *api.ChainRecord

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) QueryChains

func (h *Harness) QueryChains(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainRecord]

QueryChains queries the Harness's service, passing the given arguments. QueryChains fails if Query returns an error. See api.Querier2.QueryChains.

func (*Harness) QueryDataEntries

func (h *Harness) QueryDataEntries(scope *url.URL, query *api.DataQuery) *api.RecordRange[*api.ChainEntryRecord[*api.TransactionRecord]]

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.TransactionRecord]

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) QueryIdxChainEntries

func (h *Harness) QueryIdxChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.IndexEntryRecord]]

QueryIdxChainEntries queries the Harness's service, passing the given arguments. QueryIdxChainEntries fails if Query returns an error. See api.Querier2.QueryIdxChainEntries.

func (*Harness) QueryIdxChainEntry

func (h *Harness) QueryIdxChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.IndexEntryRecord]

QueryIdxChainEntry queries the Harness's service, passing the given arguments. QueryIdxChainEntry fails if Query returns an error. See api.Querier2.QueryIdxChainEntry.

func (*Harness) QueryMajorBlock

func (h *Harness) QueryMajorBlock(scope *url.URL, query *api.BlockQuery) *api.MajorBlockRecord

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) QueryMinorBlock

func (h *Harness) QueryMinorBlock(scope *url.URL, query *api.BlockQuery) *api.MinorBlockRecord

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.TransactionRecord]

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) QuerySigChainEntries

func (h *Harness) QuerySigChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.SignatureRecord]]

QuerySigChainEntries queries the Harness's service, passing the given arguments. QuerySigChainEntries fails if Query returns an error. See api.Querier2.QuerySigChainEntries.

func (*Harness) QuerySigChainEntry

func (h *Harness) QuerySigChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.SignatureRecord]

QuerySigChainEntry queries the Harness's service, passing the given arguments. QuerySigChainEntry fails if Query returns an error. See api.Querier2.QuerySigChainEntry.

func (*Harness) QueryTransaction

func (h *Harness) QueryTransaction(txid *url.TxID, query *api.DefaultQuery) *api.TransactionRecord

QueryTransaction queries the Harness's service, passing the given arguments. QueryTransaction fails if Query returns an error. See api.Querier2.QueryTransaction.

func (*Harness) QueryTxnChainEntries

func (h *Harness) QueryTxnChainEntries(scope *url.URL, query *api.ChainQuery) *api.RecordRange[*api.ChainEntryRecord[*api.TransactionRecord]]

QueryTxnChainEntries queries the Harness's service, passing the given arguments. QueryTxnChainEntries fails if Query returns an error. See api.Querier2.QueryTxnChainEntries.

func (*Harness) QueryTxnChainEntry

func (h *Harness) QueryTxnChainEntry(scope *url.URL, query *api.ChainQuery) *api.ChainEntryRecord[*api.TransactionRecord]

QueryTxnChainEntry queries the Harness's service, passing the given arguments. QueryTxnChainEntry fails if Query returns an error. See api.Querier2.QueryTxnChainEntry.

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) 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) SearchForTransactionHash

func (h *Harness) SearchForTransactionHash(scope *url.URL, search *api.TransactionHashSearchQuery) *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) Step

func (h *Harness) Step()

Step calls the stepper once.

func (*Harness) StepN

func (h *Harness) StepN(n int)

StepN calls the stepper N times.

func (*Harness) StepUntil

func (h *Harness) StepUntil(conditions ...Condition)

StepUntil calls the stepper until all conditions are met. StepUntil fails if the conditions are not met within 50 steps.

func (*Harness) Submit

func (h *Harness) Submit(delivery *chain.Delivery) *protocol.TransactionStatus

Submit submits a delivery and returns the status.

func (*Harness) SubmitSuccessfully

func (h *Harness) SubmitSuccessfully(delivery *chain.Delivery) *protocol.TransactionStatus

SubmitSuccessfully submits a delivery and returns the status. SubmitSuccessfully fails if the transaction failed.

type Services

type Services interface {
	api.Querier
	api.Submitter
	api.NetworkService
}

Services defines the services required by the harness.

type Sim

type Sim struct {
	Harness
	// contains filtered or unexported fields
}

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

func NewSimWith(tb testing.TB, s *simulator.Simulator) *Sim

NewSimWith creates a Harness for the given simulator instance and wraps it as a Sim.

func (*Sim) Database

func (s *Sim) Database(partition string) database.Updater

Database calls Simulator.Database.

func (*Sim) DatabaseFor

func (s *Sim) DatabaseFor(account *url.URL) database.Updater

DatabaseFor calls Simulator.DatabaseFor.

func (*Sim) Partitions

func (s *Sim) Partitions() []*protocol.PartitionInfo

Partitions calls Simulator.Partitions.

func (*Sim) Router

func (s *Sim) Router() routing.Router

Router calls Simulator.Router.

func (*Sim) SetRoute

func (s *Sim) SetRoute(account *url.URL, partition string)

SetRoute calls Simulator.SetRoute.

func (*Sim) SetSubmitHook

func (s *Sim) SetSubmitHook(partition string, fn simulator.SubmitHookFunc)

SetSubmitHook calls Simulator.SetSubmitHook.

func (*Sim) SignWithNode

func (s *Sim) SignWithNode(partition string, i int) signing.Signer

SignWithNode calls Simulator.SignWithNode.

func (*Sim) SubmitTo

func (s *Sim) SubmitTo(partition string, delivery *chain.Delivery) (*protocol.TransactionStatus, error)

type Stepper

type Stepper interface {
	Step() error
}

Stepper steps the simulation or waits for a block to complete.

type TimeStep

type TimeStep time.Duration

TimeStep implements Stepper by sleeping.

func (TimeStep) Step

func (t TimeStep) Step() error

Step waits for some duration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL