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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

events_test.go 879B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package mtglib_test
  2. import (
  3. "net"
  4. "testing"
  5. "time"
  6. "github.com/9seconds/mtg/v2/mtglib"
  7. "github.com/stretchr/testify/suite"
  8. )
  9. type EventsTestSuite struct {
  10. suite.Suite
  11. }
  12. func (suite *EventsTestSuite) TestEventStart() {
  13. evt := mtglib.EventStart{
  14. CreatedAt: time.Now(),
  15. ConnID: "CONNID",
  16. RemoteIP: net.ParseIP("10.0.0.10"),
  17. }
  18. suite.Equal("CONNID", evt.StreamID())
  19. }
  20. func (suite *EventsTestSuite) TestEventFinish() {
  21. evt := mtglib.EventFinish{
  22. CreatedAt: time.Now(),
  23. ConnID: "CONNID",
  24. }
  25. suite.Equal("CONNID", evt.StreamID())
  26. }
  27. func (suite *EventsTestSuite) TestEventConcurrencyLimited() {
  28. suite.Empty(mtglib.EventConcurrencyLimited{}.StreamID())
  29. }
  30. func (suite *EventsTestSuite) TestEventIPBlocklisted() {
  31. suite.Empty(mtglib.EventIPBlocklisted{}.StreamID())
  32. }
  33. func TestEvents(t *testing.T) {
  34. t.Parallel()
  35. suite.Run(t, &EventsTestSuite{})
  36. }