github.com/consensys/gnark-crypto@v0.14.0/internal/generator/hash_to_field/template/hash_to_field_test.go.tmpl (about)

     1  import (
     2      "testing"
     3  
     4      "{{ .FieldPackagePath }}"
     5  )
     6  
     7  func TestHashInterface(t *testing.T) {
     8  	msg := []byte("test")
     9  	sep := []byte("separator")
    10  	res, err := {{ .FieldPackageName}}.Hash(msg, sep, 1)
    11  	if err != nil {
    12  		t.Fatal("hash to field", err)
    13  	}
    14  
    15  	htfFn := New(sep)
    16  	htfFn.Write(msg)
    17  	bts := htfFn.Sum(nil)
    18  	var res2 {{ .ElementType }}
    19  	res2.SetBytes(bts[:{{ .FieldPackageName }}.Bytes])
    20  	if !res[0].Equal(&res2) {
    21  		t.Error("not equal")
    22  	}
    23  }