func (t *SignerTest) BenchmarkTimeVerify(c *C) { s := signer.NewTimeSigner(h) msg := []byte{0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x85, 0xc5, 0xc2, 0xd, 0x33, 0xc0, 0x28, 0xd7, 0xda, 0x70, 0xdc, 0x85, 0x37, 0x3f, 0xe7, 0x40} for i := 0; i < c.N; i++ { s.Verify(msg, time.Minute) } }
func (t *SignerTest) BenchmarkTimeSign(c *C) { s := signer.NewTimeSigner(h) data := []byte("hello") for i := 0; i < c.N; i++ { s.Sign(data) } }
func (t *SignerTest) TestTimeSignerZeroDuration(c *C) { s := signer.NewTimeSigner(h) data := []byte("hello") msg := s.Sign(data) data2, ok := s.Verify(msg, 0) c.Assert(ok, Equals, false) c.Assert(data2, IsNil) }
func (t *SignerTest) TestTimeSigner(c *C) { s := signer.NewTimeSigner(h) data := []byte("hello") msg := s.Sign(data) data2, ok := s.Verify(msg, time.Minute) c.Assert(ok, Equals, true) c.Assert(data2, DeepEquals, data) }