Documentation
¶
Index ¶
- func GetMessage[In any, Out any](w *cardinal.World) (*cardinal.MessageType[In, Out], error)
- func SetTestTimeout(t *testing.T, timeout time.Duration)
- func UniqueSignature() *sign.Transaction
- func UniqueSignatureWithName(name string) *sign.Transaction
- type TestFixture
- func (t *TestFixture) AddTransaction(txID types.MessageID, tx any, sigs ...*sign.Transaction) types.TxHash
- func (t *TestFixture) CreatePersona(personaTag, signerAddr string)
- func (t *TestFixture) DoTick()
- func (t *TestFixture) Get(path string) *http.Response
- func (t *TestFixture) Post(path string, payload any) *http.Response
- func (t *TestFixture) StartWorld()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMessage ¶
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.