Fix timestamp tests

This commit is contained in:
Andy Wang 2020-11-24 19:00:02 +00:00
parent b7e7bfb314
commit 095471103a
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374
1 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import (
"time" "time"
) )
func TestTouchStone(t *testing.T) { func TestDecryptClientInfo(t *testing.T) {
pvBytes, _ := hex.DecodeString("10de5a3c4a4d04efafc3e06d1506363a72bd6d053baef123e6a9a79a0c04b547") pvBytes, _ := hex.DecodeString("10de5a3c4a4d04efafc3e06d1506363a72bd6d053baef123e6a9a79a0c04b547")
p, _ := ecdh.Unmarshal(pvBytes) p, _ := ecdh.Unmarshal(pvBytes)
staticPv := p.(crypto.PrivateKey) staticPv := p.(crypto.PrivateKey)
@ -49,7 +49,7 @@ func TestTouchStone(t *testing.T) {
t.Errorf("expecting no error, got %v", err) t.Errorf("expecting no error, got %v", err)
return return
} }
nineSixSixM50 := time.Unix(1565998966, 0).Truncate(50) nineSixSixM50 := time.Unix(1565998966, 0).Add(-50)
_, err = decryptClientInfo(ai, nineSixSixM50) _, err = decryptClientInfo(ai, nineSixSixM50)
if err != nil { if err != nil {
t.Errorf("expecting no error, got %v", err) t.Errorf("expecting no error, got %v", err)
@ -82,7 +82,7 @@ func TestTouchStone(t *testing.T) {
return return
} }
nineSixSixUnder := time.Unix(1565998966, 0).Add(timestampTolerance - 10) nineSixSixUnder := time.Unix(1565998966, 0).Add(-(timestampTolerance + 10))
_, err = decryptClientInfo(ai, nineSixSixUnder) _, err = decryptClientInfo(ai, nineSixSixUnder)
if err == nil { if err == nil {
t.Errorf("expecting %v, got %v", ErrTimestampOutOfWindow, err) t.Errorf("expecting %v, got %v", ErrTimestampOutOfWindow, err)