rpc

package
v0.0.0-...-f34c588 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const InactivityThreshold = 60 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCreationOpts

type ClientCreationOpts struct {
	api.ClientCreationOpts
	Lang      api.ClientTypeLang // need to know the type for pulling out the corret bindings
	ContextID string
}

type LanguageBindings

type LanguageBindings struct {
	// contains filtered or unexported fields
}

LanguageBindings implements api.LanguageBindings and instead issues RPC calls to a remote server.

func NewLanguageBindings

func NewLanguageBindings(rpcBinaryPath string, clientType api.ClientTypeLang, contextPrefix string) (*LanguageBindings, error)

func (*LanguageBindings) MustCreateClient

func (r *LanguageBindings) MustCreateClient(t ct.TestLike, cfg api.ClientCreationOpts) api.Client

MustCreateClient starts the RPC server and configures it to use the correct language. Returns an error if:

  • the binary cannot be found or run
  • the server cannot be started
  • IPC via stdout fails (used to extract the random high numbered port)
  • the client cannot talk to the rpc server

func (*LanguageBindings) PostTestRun

func (r *LanguageBindings) PostTestRun(contextID string)

func (*LanguageBindings) PreTestRun

func (r *LanguageBindings) PreTestRun(contextID string)

type RPCBackpaginate

type RPCBackpaginate struct {
	TestName string
	RoomID   string
	Count    int
}

Backpaginate in this room by `count` events.

type RPCCheck

type RPCCheck struct {
}

type RPCClient

type RPCClient struct {
	// contains filtered or unexported fields
}

RPCClient implements api.Client by making RPC calls to an RPC server, which actually has a concrete api.Client

func (*RPCClient) Backpaginate

func (c *RPCClient) Backpaginate(t ct.TestLike, roomID string, count int) error

Backpaginate in this room by `count` events.

func (*RPCClient) BackupKeys

func (c *RPCClient) BackupKeys(t ct.TestLike) (recoveryKey string, err error)

BackupKeys will backup E2EE keys, else return an error.

func (*RPCClient) Close

func (c *RPCClient) Close(t ct.TestLike)

Close is called to clean up resources. Specifically, we need to shut off existing browsers and any FFI bindings. If we get callbacks/events after this point, tests may panic if the callbacks log messages.

func (*RPCClient) CurrentAccessToken

func (c *RPCClient) CurrentAccessToken(t ct.TestLike) string

func (*RPCClient) DeletePersistentStorage

func (c *RPCClient) DeletePersistentStorage(t ct.TestLike)

Remove any persistent storage, if it was enabled.

func (*RPCClient) ForceClose

func (c *RPCClient) ForceClose(t ct.TestLike)

func (*RPCClient) GetEvent

func (c *RPCClient) GetEvent(t ct.TestLike, roomID, eventID string) (*api.Event, error)

GetEvent will return the client's view of this event, or return an error if the event cannot be found.

func (*RPCClient) GetNotification

func (c *RPCClient) GetNotification(t ct.TestLike, roomID, eventID string) (*api.Notification, error)

func (*RPCClient) InviteUser

func (c *RPCClient) InviteUser(t ct.TestLike, roomID, userID string) error

func (*RPCClient) IsRoomEncrypted

func (c *RPCClient) IsRoomEncrypted(t ct.TestLike, roomID string) (bool, error)

IsRoomEncrypted returns true if the room is encrypted. May return an error e.g if you provide a bogus room ID.

func (*RPCClient) ListenForVerificationRequests

func (c *RPCClient) ListenForVerificationRequests(t ct.TestLike) chan api.VerificationStage

func (*RPCClient) LoadBackup

func (c *RPCClient) LoadBackup(t ct.TestLike, recoveryKey string) error

LoadBackup will recover E2EE keys from the latest backup, else return an error.

func (*RPCClient) Logf

func (c *RPCClient) Logf(t ct.TestLike, format string, args ...interface{})

Log something to stdout and the underlying client log file

func (*RPCClient) Login

func (c *RPCClient) Login(t ct.TestLike, opts api.ClientCreationOpts) error

func (*RPCClient) Opts

func (c *RPCClient) Opts() api.ClientCreationOpts

func (*RPCClient) RequestOwnUserVerification

func (c *RPCClient) RequestOwnUserVerification(t ct.TestLike) chan api.VerificationStage

func (*RPCClient) SendMessage

func (c *RPCClient) SendMessage(t ct.TestLike, roomID, text string) (eventID string, err error)

SendMessage tries to send the message, but can fail.

func (*RPCClient) StartSyncing

func (c *RPCClient) StartSyncing(t ct.TestLike) (stopSyncing func(), err error)

StartSyncing to begin syncing from sync v2 / sliding sync. Tests should call stopSyncing() at the end of the test. MUST BLOCK until the initial sync is complete. Returns an error if there was a problem syncing.

func (*RPCClient) Type

func (c *RPCClient) Type() api.ClientTypeLang

func (*RPCClient) UserID

func (c *RPCClient) UserID() string

func (*RPCClient) WaitUntilEventInRoom

func (c *RPCClient) WaitUntilEventInRoom(t ct.TestLike, roomID string, checker func(e api.Event) bool) api.Waiter

Wait until an event is seen in the given room. The checker functions can be custom or you can use a pre-defined one like api.CheckEventHasMembership, api.CheckEventHasBody, or api.CheckEventHasEventID.

type RPCGetEvent

type RPCGetEvent struct {
	TestName string
	RoomID   string
	EventID  string
}

type RPCGetNotification

type RPCGetNotification struct {
	RoomID  string
	EventID string
}

type RPCSendMessage

type RPCSendMessage struct {
	TestName string
	RoomID   string
	Text     string
}

type RPCServerWaiter

type RPCServerWaiter struct {
	api.Waiter
	// contains filtered or unexported fields
}

type RPCWait

type RPCWait struct {
	TestName string
	WaiterID int
	Msg      string
	Timeout  time.Duration
}

type RPCWaitUntilEvent

type RPCWaitUntilEvent struct {
	TestName string
	RoomID   string
}

type RPCWaiter

type RPCWaiter struct {
	// contains filtered or unexported fields
}

func (*RPCWaiter) TryWaitf

func (w *RPCWaiter) TryWaitf(t ct.TestLike, s time.Duration, format string, args ...any) error

func (*RPCWaiter) Waitf

func (w *RPCWaiter) Waitf(t ct.TestLike, s time.Duration, format string, args ...any)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server exposes the api.Client interface over the wire, consumed via net/rpc. Args and return params must be encodable with encoding/gob. All functions on this struct must meet the form:

func (t *T) MethodName(argType T1, replyType *T2) error

func NewServer

func NewServer() *Server

func (*Server) Backpaginate

func (s *Server) Backpaginate(input RPCBackpaginate, void *int) error

func (*Server) BackupKeys

func (s *Server) BackupKeys(testName string, recoveryKey *string) error

BackupKeys will backup E2EE keys, else fail the test.

func (*Server) Close

func (s *Server) Close(testName string, void *int) error

func (*Server) CurrentAccessToken

func (s *Server) CurrentAccessToken(testName string, token *string) error

func (*Server) DeletePersistentStorage

func (s *Server) DeletePersistentStorage(testName string, void *int) error

func (*Server) GetEvent

func (s *Server) GetEvent(input RPCGetEvent, output *api.Event) error

GetEvent will return the client's view of this event, or returns an error if the event cannot be found.

func (*Server) GetNotification

func (s *Server) GetNotification(input RPCGetNotification, output *api.Notification) (err error)

func (*Server) IsRoomEncrypted

func (s *Server) IsRoomEncrypted(roomID string, isEncrypted *bool) error

func (*Server) LoadBackup

func (s *Server) LoadBackup(recoveryKey string, void *int) error

func (*Server) Logf

func (s *Server) Logf(input string, void *int) error

func (*Server) Login

func (s *Server) Login(opts api.ClientCreationOpts, void *int) error

func (*Server) MustCreateClient

func (s *Server) MustCreateClient(opts ClientCreationOpts, void *int) error

MustCreateClient creates a given client and returns it to the caller, else returns an error.

func (*Server) Opts

func (s *Server) Opts(void int, opts *api.ClientCreationOpts) error

func (*Server) SendMessage

func (s *Server) SendMessage(msg RPCSendMessage, eventID *string) error

func (*Server) StartSyncing

func (s *Server) StartSyncing(testName string, void *int) error

func (*Server) StopSyncing

func (s *Server) StopSyncing(testName string, void *int) error

func (*Server) Type

func (s *Server) Type(void int, clientType *api.ClientTypeLang) error

func (*Server) UserID

func (s *Server) UserID(void int, userID *string) error

func (*Server) WaitUntilEventInRoom

func (s *Server) WaitUntilEventInRoom(input RPCWaitUntilEvent, waiterID *int) error

func (*Server) WaiterPoll

func (s *Server) WaiterPoll(waiterID int, eventsToCheck *[]api.Event) error

func (*Server) WaiterStart

func (s *Server) WaiterStart(input RPCWait, void *int) error

WaiterStart is the RPC equivalent to Waiter.Waitf. It begins accumulating events for the RPC client to check. Clients need to call WaiterPoll to get these new events.

Jump to

Keyboard shortcuts

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