testutils

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMessage

func GetMessage[In any, Out any](wCtx engine.Context) (*message.MessageType[In, Out], error)

func SetTestTimeout

func SetTestTimeout(t *testing.T, timeout time.Duration)

func UniqueSignature

func UniqueSignature() *sign.Transaction

func UniqueSignatureWithName

func UniqueSignatureWithName(name string) *sign.Transaction

Types

type TestFixture

type TestFixture struct {
	testing.TB

	// Base url is something like "localhost:5050". You must attach http:// or ws:// as well as a resource path
	BaseURL string
	World   *cardinal.World
	Redis   *miniredis.Miniredis

	StartTickCh chan time.Time
	DoneTickCh  chan uint64
	// contains filtered or unexported fields
}

TestFixture is a helper struct that manages a cardinal.World instance. It will automatically clean up its resources at the end of the test.

func NewTestFixture

func NewTestFixture(t testing.TB, redis *miniredis.Miniredis, opts ...cardinal.WorldOption) *TestFixture

NewTestFixture creates a test fixture with user defined port for Cardinal integration tests.

func (*TestFixture) AddTransaction

func (t *TestFixture) AddTransaction(txID types.MessageID, tx any, sigs ...*sign.Transaction) types.TxHash

func (*TestFixture) CreatePersona

func (t *TestFixture) CreatePersona(personaTag, signerAddr string)

func (*TestFixture) DoTick

func (t *TestFixture) DoTick()

DoTick executes one game tick and blocks until the tick is complete. StartWorld is automatically called if it was not called before the first tick.

func (*TestFixture) Get

func (t *TestFixture) Get(path string) *http.Response

Get executes a http GET request to this TestFixture's cardinal server.

func (*TestFixture) Post

func (t *TestFixture) Post(path string, payload any) *http.Response

Post executes a http POST request to this TextFixture's cardinal server.

func (*TestFixture) StartWorld

func (t *TestFixture) StartWorld()

StartWorld starts the game world and registers a cleanup function that will shut down the cardinal World at the end of the test. Components/Systems/Queries, etc should be registered before calling this function.

Jump to

Keyboard shortcuts

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