tgtest

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package tgtest provides test Telegram server for end-to-end test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedConn added in v0.15.1

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

func NewBufferedConn added in v0.15.1

func NewBufferedConn(conn transport.Conn) *BufferedConn

func (*BufferedConn) Close added in v0.15.1

func (c *BufferedConn) Close() error

func (*BufferedConn) Push added in v0.15.1

func (c *BufferedConn) Push(b *bin.Buffer)

func (*BufferedConn) Recv added in v0.15.1

func (c *BufferedConn) Recv(ctx context.Context, b *bin.Buffer) error

func (*BufferedConn) Send added in v0.15.1

func (c *BufferedConn) Send(ctx context.Context, b *bin.Buffer) error

type Handler added in v0.11.0

type Handler interface {
	OnMessage(s Session, msgID int64, in *bin.Buffer) error
}

type HandlerFunc added in v0.12.0

type HandlerFunc func(s Session, msgID int64, in *bin.Buffer) error

HandlerFunc is functional adapter for Handler.OnMessage method.

func (HandlerFunc) OnMessage added in v0.12.0

func (h HandlerFunc) OnMessage(s Session, msgID int64, in *bin.Buffer) error

type Server

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

func NewServer

func NewServer(name string, suite Suite, codec func() transport.Codec, h Handler) *Server

func NewUnstartedServer

func NewUnstartedServer(name string, suite Suite, codec func() transport.Codec) *Server

func TestTransport added in v0.12.0

func TestTransport(s Suite, message string, codec func() transport.Codec) *Server

func (*Server) AddSession added in v0.21.0

func (s *Server) AddSession(key crypto.AuthKey)

func (*Server) Addr added in v0.11.2

func (s *Server) Addr() net.Addr

func (*Server) Close

func (s *Server) Close()

func (*Server) ForceDisconnect added in v0.12.0

func (s *Server) ForceDisconnect(k Session)

func (*Server) Key

func (s *Server) Key() *rsa.PublicKey

func (*Server) Send added in v0.11.0

func (s *Server) Send(k Session, t proto.MessageType, encoder bin.Encoder) error

func (*Server) SendAck added in v0.12.0

func (s *Server) SendAck(k Session, ids ...int64) error

func (*Server) SendConfig added in v0.12.0

func (s *Server) SendConfig(k Session, id int64) error

func (*Server) SendEternalSalt added in v0.28.0

func (s *Server) SendEternalSalt(k Session, msgID int64) error

func (*Server) SendFutureSalts added in v0.28.0

func (s *Server) SendFutureSalts(k Session, msgID int64, salts ...proto.FutureSalt) error

func (*Server) SendPong added in v0.12.0

func (s *Server) SendPong(k Session, msgID, pingID int64) error

func (*Server) SendResult added in v0.11.0

func (s *Server) SendResult(k Session, id int64, msg bin.Encoder) error

func (*Server) SendUpdates added in v0.12.0

func (s *Server) SendUpdates(k Session, updates ...tg.UpdateClass) error

func (*Server) Serve added in v0.15.0

func (s *Server) Serve() error

func (*Server) SetHandler added in v0.11.0

func (s *Server) SetHandler(handler Handler)

func (*Server) SetHandlerFunc added in v0.12.0

func (s *Server) SetHandlerFunc(handler func(s Session, msgID int64, in *bin.Buffer) error)

func (*Server) Start

func (s *Server) Start()

type Session added in v0.11.0

type Session struct {
	SessionID int64
	crypto.AuthKey
}

type Suite added in v0.12.0

type Suite struct {
	testing.TB
	Ctx context.Context
	Log *zap.Logger
}

func NewSuite added in v0.12.0

func NewSuite(ctx context.Context, tb testing.TB, log *zap.Logger) Suite

type TB

type TB interface {
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Fatal(args ...interface{})
}

Jump to

Keyboard shortcuts

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