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.

detector_test.go 622B

12345678910111213141516171819202122232425262728
  1. package timeattack_test
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/9seconds/mtg/v2/timeattack"
  6. "github.com/stretchr/testify/suite"
  7. )
  8. type DetectorTestSuite struct {
  9. suite.Suite
  10. }
  11. func (suite *DetectorTestSuite) TestOp() {
  12. d := timeattack.NewDetector(time.Second)
  13. suite.NoError(d.Valid(time.Now()))
  14. suite.NoError(d.Valid(time.Now().Add(100 * time.Millisecond)))
  15. suite.NoError(d.Valid(time.Now().Add(-100 * time.Millisecond)))
  16. suite.Error(d.Valid(time.Now().Add(time.Hour)))
  17. suite.Error(d.Valid(time.Now().Add(-time.Hour)))
  18. }
  19. func TestDetector(t *testing.T) {
  20. t.Parallel()
  21. suite.Run(t, &DetectorTestSuite{})
  22. }