Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

init_internal_test.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package network
  2. import (
  3. "context"
  4. "net"
  5. "time"
  6. "github.com/stretchr/testify/mock"
  7. )
  8. type ConnMock struct {
  9. mock.Mock
  10. }
  11. func (c *ConnMock) Read(b []byte) (int, error) {
  12. args := c.Called(b)
  13. return args.Int(0), args.Error(1)
  14. }
  15. func (c *ConnMock) Write(b []byte) (int, error) {
  16. args := c.Called(b)
  17. return args.Int(0), args.Error(1)
  18. }
  19. func (c *ConnMock) Close() error {
  20. return c.Called().Error(0)
  21. }
  22. func (c *ConnMock) LocalAddr() net.Addr {
  23. return c.Called().Get(0).(net.Addr)
  24. }
  25. func (c *ConnMock) RemoteAddr() net.Addr {
  26. return c.Called().Get(0).(net.Addr)
  27. }
  28. func (c *ConnMock) SetDeadline(t time.Time) error {
  29. return c.Called(t).Error(0)
  30. }
  31. func (c *ConnMock) SetReadDeadline(t time.Time) error {
  32. return c.Called(t).Error(0)
  33. }
  34. func (c *ConnMock) SetWriteDeadline(t time.Time) error {
  35. return c.Called(t).Error(0)
  36. }
  37. type DialerMock struct {
  38. mock.Mock
  39. }
  40. func (d *DialerMock) Dial(network, address string) (net.Conn, error) {
  41. args := d.Called(network, address)
  42. return args.Get(0).(net.Conn), args.Error(1)
  43. }
  44. func (d *DialerMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
  45. args := d.Called(ctx, network, address)
  46. return args.Get(0).(net.Conn), args.Error(1)
  47. }