Merge pull request #1784 from filecoin-project/feat/update-serialization-vectors
update serialization vectors
This commit is contained in:
commit
59725b3af3
@ -1,11 +1,15 @@
|
||||
package vectors
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
func LoadVector(t *testing.T, f string, out interface{}) {
|
||||
@ -42,5 +46,40 @@ func TestBlockHeaderVectors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMessageSigningVectors(t *testing.T) {
|
||||
// TODO:
|
||||
var msvs []MessageSigningVector
|
||||
LoadVector(t, "message_signing.json", &msvs)
|
||||
|
||||
for i, msv := range msvs {
|
||||
smsg := &types.SignedMessage{
|
||||
Message: *msv.Unsigned,
|
||||
Signature: *msv.Signature,
|
||||
}
|
||||
|
||||
if smsg.Cid().String() != msv.Cid {
|
||||
t.Fatalf("cid of message in vector %d mismatches", i)
|
||||
}
|
||||
|
||||
// TODO: check signature
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnsignedMessageVectors(t *testing.T) {
|
||||
var msvs []UnsignedMessageVector
|
||||
LoadVector(t, "unsigned_messages.json", &msvs)
|
||||
|
||||
for i, msv := range msvs {
|
||||
b, err := msv.Message.Serialize()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dec, err := hex.DecodeString(msv.HexCbor)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(b, dec) {
|
||||
t.Fatalf("serialization vector %d mismatches bytes", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
extern/serialization-vectors
vendored
2
extern/serialization-vectors
vendored
@ -1 +1 @@
|
||||
Subproject commit 1e778d5bd77f758e83a18c41d10c2649b0e70fef
|
||||
Subproject commit 0cef69d481950d24f0e26e2698e585a8bf203913
|
Loading…
Reference in New Issue
Block a user