simulator

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 27 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)

Functions

func GetAccount

func GetAccount[T protocol.Account](sim *Simulator, accountUrl *url.URL) T

func GetTxnState

func GetTxnState[V any, T interface{ Get() (V, error) }](sim *Simulator, txid *url.TxID, state func(*database.Transaction) T) V

Types

type FakeNode

type FakeNode struct {
	H *harness.Sim
	// contains filtered or unexported fields
}

FakeNode is a compatibility shim for tests based on abci_test.FakeNode.

func NewFakeNode

func NewFakeNode(t testing.TB, errorHandler func(err error)) *FakeNode

func NewFakeNodeV1

func NewFakeNodeV1(t testing.TB, errorHandler func(err error)) *FakeNode

func (*FakeNode) Assert

func (n *FakeNode) Assert() *assert.Assertions

func (*FakeNode) Execute

func (n *FakeNode) Execute(inBlock func(func(*messaging.Envelope))) (sigHashes, txnHashes [][32]byte, err error)

func (*FakeNode) GetADI

func (n *FakeNode) GetADI(s string) *protocol.ADI

func (*FakeNode) GetDataAccount

func (n *FakeNode) GetDataAccount(s string) *protocol.DataAccount

func (*FakeNode) GetDataEntry

func (n *FakeNode) GetDataEntry(s string, q *api.DataQuery) protocol.DataEntry

func (*FakeNode) GetDirectory

func (n *FakeNode) GetDirectory(s string) []string

func (*FakeNode) GetKeyBook

func (n *FakeNode) GetKeyBook(s string) *protocol.KeyBook

func (*FakeNode) GetKeyPage

func (n *FakeNode) GetKeyPage(s string) *protocol.KeyPage

func (*FakeNode) GetLiteDataAccount

func (n *FakeNode) GetLiteDataAccount(s string) *protocol.LiteDataAccount

func (*FakeNode) GetLiteIdentity

func (n *FakeNode) GetLiteIdentity(s string) *protocol.LiteIdentity

func (*FakeNode) GetLiteTokenAccount

func (n *FakeNode) GetLiteTokenAccount(s string) *protocol.LiteTokenAccount

func (*FakeNode) GetOraclePrice

func (n *FakeNode) GetOraclePrice() uint64

func (*FakeNode) GetTokenAccount

func (n *FakeNode) GetTokenAccount(s string) *protocol.TokenAccount

func (*FakeNode) GetTokenIssuer

func (n *FakeNode) GetTokenIssuer(s string) *protocol.TokenIssuer

func (*FakeNode) MustExecute

func (n *FakeNode) MustExecute(inBlock func(func(*messaging.Envelope))) (sigHashes, txnHashes [][32]byte)

func (*FakeNode) MustExecuteAndWait

func (n *FakeNode) MustExecuteAndWait(inBlock func(func(*messaging.Envelope))) [][32]byte

func (*FakeNode) QueryAccountAs

func (n *FakeNode) QueryAccountAs(s string, result any)

func (*FakeNode) QueryTx

func (n *FakeNode) QueryTx(txid []byte, wait time.Duration, ignorePending bool) *api.MessageRecord[*messaging.TransactionMessage]

func (*FakeNode) Require

func (n *FakeNode) Require() *require.Assertions

func (*FakeNode) T

func (n *FakeNode) T() testing.TB

func (*FakeNode) Update

func (n *FakeNode) Update(fn func(batch *database.Batch))

func (*FakeNode) View

func (n *FakeNode) View(fn func(batch *database.Batch))

type Partition

type Partition struct {
	ID string

	Database database.Beginner
	API      *client.Client
	Executor struct {
		Key      []byte
		Describe config.Describe
	}

	database.Beginner
	// contains filtered or unexported fields
}

func (*Partition) Globals

func (p *Partition) Globals() *core.GlobalValues

type Simulator

type Simulator struct {
	S *simulator.Simulator
	H *harness.Sim

	// setup
	TB testing.TB
	// contains filtered or unexported fields
}

func New

func New(t testing.TB, bvnCount int) *Simulator

func NewWith

func NewWith(t testing.TB, opts SimulatorOptions) *Simulator

func (*Simulator) CreateAccount

func (s *Simulator) CreateAccount(account protocol.Account)

func (*Simulator) CreateIdentity

func (s *Simulator) CreateIdentity(identityUrl *url.URL, pubKey ...[]byte)

func (*Simulator) CreateKeyBook

func (s *Simulator) CreateKeyBook(bookUrl *url.URL, pubKey ...[]byte)

func (*Simulator) CreateKeyPage

func (s *Simulator) CreateKeyPage(bookUrl *url.URL, pubKey ...[]byte)

func (*Simulator) CreateLiteTokenAccount

func (s *Simulator) CreateLiteTokenAccount(key []byte, token *url.URL, credits, tokens uint64) *url.URL

func (*Simulator) ExecuteBlock

func (s *Simulator) ExecuteBlock(interface{ x() })

func (*Simulator) ExecuteBlocks

func (s *Simulator) ExecuteBlocks(n int)

func (*Simulator) Init

func (s *Simulator) Init(from simulator.SnapshotFunc)

func (*Simulator) InitFromGenesis

func (s *Simulator) InitFromGenesis()

func (*Simulator) InitFromGenesisWith

func (s *Simulator) InitFromGenesisWith(values *core.GlobalValues)

func (*Simulator) InitFromSnapshot

func (s *Simulator) InitFromSnapshot(filename func(string) string)

func (*Simulator) MustSubmitAndExecuteBlock

func (s *Simulator) MustSubmitAndExecuteBlock(envelopes ...*messaging.Envelope) []*messaging.Envelope

func (*Simulator) Partition

func (s *Simulator) Partition(part string) *Partition

func (*Simulator) PartitionFor

func (s *Simulator) PartitionFor(u *url.URL) *Partition

func (*Simulator) Router

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

func (*Simulator) SetRouteFor

func (s *Simulator) SetRouteFor(u *url.URL, p string)

func (*Simulator) Setup

func (sim *Simulator) Setup(opts SimulatorOptions)

func (*Simulator) Submit

func (s *Simulator) Submit(envelopes ...*messaging.Envelope) ([]*messaging.Envelope, error)

func (*Simulator) SubmitAndExecuteBlock

func (s *Simulator) SubmitAndExecuteBlock(envelopes ...*messaging.Envelope) ([]*protocol.TransactionStatus, error)

func (*Simulator) UpdateAccount

func (s *Simulator) UpdateAccount(accountUrl *url.URL, fn func(account protocol.Account))

func (*Simulator) WaitForTransaction

func (s *Simulator) WaitForTransaction(statusCheck func(*protocol.TransactionStatus) bool, txnHash []byte, n int) (*protocol.Transaction, *protocol.TransactionStatus, []*url.TxID)

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 ...*messaging.Envelope) ([]*protocol.TransactionStatus, []*protocol.Transaction)

type SimulatorOptions

type SimulatorOptions struct {
	BvnCount  int
	LogLevels string
	OpenDB    simulator.OpenDatabaseFunc
	Snapshots []func() (ioutil2.SectionReader, error)
}

Jump to

Keyboard shortcuts

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