9a17beba9e
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
47 lines
886 B
Go
47 lines
886 B
Go
package vectors
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func LoadVector(t *testing.T, f string, out interface{}) {
|
|
p := filepath.Join("../../extern/serialization-vectors", f)
|
|
fi, err := os.Open(p)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := json.NewDecoder(fi).Decode(out); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestBlockHeaderVectors(t *testing.T) {
|
|
t.Skip("we need to regenerate for beacon")
|
|
var headers []HeaderVector
|
|
LoadVector(t, "block_headers.json", &headers)
|
|
|
|
for i, hv := range headers {
|
|
if hv.Block.Cid().String() != hv.Cid {
|
|
t.Fatalf("CID mismatch in test vector %d", i)
|
|
}
|
|
|
|
data, err := hv.Block.Serialize()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if fmt.Sprintf("%x", data) != hv.CborHex {
|
|
t.Fatalf("serialized data mismatched for test vector %d", i)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestMessageSigningVectors(t *testing.T) {
|
|
// TODO:
|
|
}
|