github.com/eagleql/xray-core@v1.4.4/proxy/vmess/encoding/auth_test.go (about) 1 package encoding_test 2 3 import ( 4 "crypto/rand" 5 "testing" 6 7 "github.com/google/go-cmp/cmp" 8 9 "github.com/eagleql/xray-core/common" 10 . "github.com/eagleql/xray-core/proxy/vmess/encoding" 11 ) 12 13 func TestFnvAuth(t *testing.T) { 14 fnvAuth := new(FnvAuthenticator) 15 16 expectedText := make([]byte, 256) 17 _, err := rand.Read(expectedText) 18 common.Must(err) 19 20 buffer := make([]byte, 512) 21 b := fnvAuth.Seal(buffer[:0], nil, expectedText, nil) 22 b, err = fnvAuth.Open(buffer[:0], nil, b, nil) 23 common.Must(err) 24 if r := cmp.Diff(b, expectedText); r != "" { 25 t.Error(r) 26 } 27 }