Documentation
¶
Index ¶
- func CreateDeleteEvent(signer *p8k.Signer, eventIDs [][]byte, reason string) (ev *event.E, err error)
- func CreateEphemeralEvent(signer *p8k.Signer, kindNum uint16, content string) (ev *event.E, err error)
- func CreateEvent(signer *p8k.Signer, kindNum uint16, content string, tags *tag.S) (ev *event.E, err error)
- func CreateEventWithTags(signer *p8k.Signer, kindNum uint16, content string, tagPairs [][]string) (ev *event.E, err error)
- func CreateParameterizedReplaceableEvent(signer *p8k.Signer, kindNum uint16, content string, dTag string) (ev *event.E, err error)
- func CreateReplaceableEvent(signer *p8k.Signer, kindNum uint16, content string) (ev *event.E, err error)
- func FormatJSON(results []TestResult) (output string, err error)
- func HexID(ev *event.E) string
- func MustHex(s string) []byte
- func RandomID() (id []byte, err error)
- type Client
- func (c *Client) Auth(ev *event.E) error
- func (c *Client) Close() error
- func (c *Client) Count(filters []interface{}) (count int64, err error)
- func (c *Client) GetEvents(subID string, filters []interface{}, timeout time.Duration) (events []*event.E, err error)
- func (c *Client) Publish(ev *event.E) (err error)
- func (c *Client) Send(msg interface{}) (err error)
- func (c *Client) Subscribe(subID string, filters []interface{}) (ch chan []byte, err error)
- func (c *Client) URL() string
- func (c *Client) Unsubscribe(subID string) error
- func (c *Client) WaitForOK(eventID []byte, timeout time.Duration) (accepted bool, reason string, err error)
- type KeyPair
- type TestCase
- type TestFunc
- type TestResult
- type TestSuite
- func (s *TestSuite) AddTest(tc *TestCase)
- func (s *TestSuite) GetResults() map[string]TestResult
- func (s *TestSuite) GetTestNames() map[string]bool
- func (s *TestSuite) ListTests() []string
- func (s *TestSuite) Run() (results []TestResult, err error)
- func (s *TestSuite) RunTest(testName string) (result TestResult, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDeleteEvent ¶
func CreateDeleteEvent(signer *p8k.Signer, eventIDs [][]byte, reason string) (ev *event.E, err error)
CreateDeleteEvent creates a deletion event (kind 5).
func CreateEphemeralEvent ¶
func CreateEphemeralEvent(signer *p8k.Signer, kindNum uint16, content string) (ev *event.E, err error)
CreateEphemeralEvent creates an ephemeral event (kind 20000-29999).
func CreateEvent ¶
func CreateEvent(signer *p8k.Signer, kindNum uint16, content string, tags *tag.S) (ev *event.E, err error)
CreateEvent creates a signed event with the given parameters.
func CreateEventWithTags ¶
func CreateEventWithTags(signer *p8k.Signer, kindNum uint16, content string, tagPairs [][]string) (ev *event.E, err error)
CreateEventWithTags creates an event with specific tags.
func CreateParameterizedReplaceableEvent ¶
func CreateParameterizedReplaceableEvent(signer *p8k.Signer, kindNum uint16, content string, dTag string) (ev *event.E, err error)
CreateParameterizedReplaceableEvent creates a parameterized replaceable event (kind 30000-39999).
func CreateReplaceableEvent ¶
func CreateReplaceableEvent(signer *p8k.Signer, kindNum uint16, content string) (ev *event.E, err error)
CreateReplaceableEvent creates a replaceable event (kind 0-3, 10000-19999).
func FormatJSON ¶
func FormatJSON(results []TestResult) (output string, err error)
FormatJSON formats results as JSON.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a WebSocket connection to a relay for testing.
func (*Client) GetEvents ¶
func (c *Client) GetEvents(subID string, filters []interface{}, timeout time.Duration) (events []*event.E, err error)
GetEvents collects all events from a subscription until EOSE.
func (*Client) Unsubscribe ¶
Unsubscribe closes a subscription.
type KeyPair ¶
KeyPair represents a test keypair.
func GenerateKeyPair ¶
GenerateKeyPair generates a new keypair for testing.
type TestCase ¶
type TestCase struct {
Name string
Required bool
Func TestFunc
Dependencies []string // Names of tests that must run before this one
}
TestCase represents a test case with dependencies.
type TestFunc ¶
type TestFunc func(client *Client, key1, key2 *KeyPair) (result TestResult)
TestFunc is a function that runs a test case.
type TestResult ¶
type TestResult struct {
Name string `json:"test"`
Pass bool `json:"pass"`
Required bool `json:"required"`
Info string `json:"info,omitempty"`
}
TestResult represents the result of a test.
type TestSuite ¶
type TestSuite struct {
// contains filtered or unexported fields
}
TestSuite runs all tests against a relay.
func NewTestSuite ¶
NewTestSuite creates a new test suite.
func (*TestSuite) GetResults ¶
func (s *TestSuite) GetResults() map[string]TestResult
GetResults returns all test results.
func (*TestSuite) GetTestNames ¶ added in v0.21.1
GetTestNames returns all registered test names as a map (name -> required).
func (*TestSuite) ListTests ¶ added in v0.21.1
ListTests returns a list of all test names in execution order.
func (*TestSuite) Run ¶
func (s *TestSuite) Run() (results []TestResult, err error)
Run runs all tests in the suite.