github.com/consensys/gnark-crypto@v0.14.0/internal/generator/fft/template/tests/domain.go.tmpl (about)

     1  
     2  import (
     3  	"reflect"
     4  	"testing"
     5  	"bytes"
     6  )
     7  
     8  func TestDomainSerialization(t *testing.T) {
     9  
    10  	domain := NewDomain(1 << 6)
    11  	var reconstructed Domain
    12  
    13  	var buf bytes.Buffer
    14  	written, err := domain.WriteTo(&buf)
    15  	if err != nil {
    16  		t.Fatal(err)
    17  	}
    18  	var read int64
    19  	read, err = reconstructed.ReadFrom(&buf)
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  
    24  	if written != read {
    25  		t.Fatal("didn't read as many bytes as we wrote")
    26  	}
    27  	if !reflect.DeepEqual(domain, &reconstructed) {
    28  		t.Fatal("Domain.SetBytes(Bytes()) failed")
    29  	}
    30  }