Merge pull request #1770 from filecoin-project/asr/test
Add an interop test for block header serialisation
This commit is contained in:
commit
a0ab3483ed
@ -2,7 +2,9 @@ package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@ -63,6 +65,62 @@ func TestBlockHeaderSerialization(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInteropBH(t *testing.T) {
|
||||
newAddr, err := address.NewSecp256k1Address([]byte("address0"))
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mcid, err := cid.Parse("bafy2bzaceaxyj7xq27gc2747adjcirpxx52tt7owqx6z6kckun7tqivvoym4y")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
posts := []abi.PoStProof{
|
||||
{abi.RegisteredProof_StackedDRG2KiBWinningPoSt, []byte{0x07}},
|
||||
}
|
||||
|
||||
bh := &BlockHeader{
|
||||
Miner: newAddr,
|
||||
Ticket: &Ticket{[]byte{0x01, 0x02, 0x03}},
|
||||
ElectionProof: &ElectionProof{[]byte{0x0a, 0x0b}},
|
||||
BeaconEntries: []BeaconEntry{
|
||||
{
|
||||
Round: 5,
|
||||
Data: []byte{0x0c},
|
||||
//prevRound: 0,
|
||||
},
|
||||
},
|
||||
Height: 2,
|
||||
Messages: mcid,
|
||||
ParentMessageReceipts: mcid,
|
||||
Parents: []cid.Cid{mcid},
|
||||
ParentWeight: NewInt(1000),
|
||||
ForkSignaling: 3,
|
||||
ParentStateRoot: mcid,
|
||||
Timestamp: 1,
|
||||
WinPoStProof: posts,
|
||||
BlockSig: &crypto.Signature{
|
||||
Type: crypto.SigTypeBLS,
|
||||
Data: []byte{0x3},
|
||||
},
|
||||
BLSAggregate: &crypto.Signature{},
|
||||
}
|
||||
|
||||
bhsb, err := bh.SigningBytes()
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// acquired from go-filecoin
|
||||
gfc := "8f5501d04cb15021bf6bd003073d79e2238d4e61f1ad22814301020381420a0b818205410c818209410781d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc430003e802d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc410001f603"
|
||||
if gfc != hex.EncodeToString(bhsb) {
|
||||
t.Fatal("not equal!")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkBlockHeaderMarshal(b *testing.B) {
|
||||
bh := testBlockHeader(b)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user