lotus/types_test.go

64 lines
1.2 KiB
Go
Raw Normal View History

package sealing
import (
"bytes"
"testing"
2020-02-27 21:45:31 +00:00
"github.com/filecoin-project/lotus/api"
2020-02-26 09:05:22 +00:00
"github.com/filecoin-project/specs-actors/actors/abi"
2020-02-27 00:42:39 +00:00
"github.com/filecoin-project/specs-actors/actors/builtin"
"gotest.tools/assert"
2020-02-27 00:42:39 +00:00
cborutil "github.com/filecoin-project/go-cbor-util"
)
func TestSectorInfoSelialization(t *testing.T) {
2020-02-26 09:05:22 +00:00
d := abi.DealID(1234)
2020-02-27 00:42:39 +00:00
dummyCid := builtin.AccountActorCodeID
si := &SectorInfo{
State: 123,
SectorID: 234,
Nonce: 345,
Pieces: []Piece{{
2020-02-26 09:05:22 +00:00
DealID: &d,
Size: 5,
2020-02-27 00:42:39 +00:00
CommP: dummyCid,
}},
2020-02-27 00:42:39 +00:00
CommD: &dummyCid,
CommR: nil,
Proof: nil,
2020-02-27 21:45:31 +00:00
Ticket: api.SealTicket{
Epoch: 345,
Value: []byte{87, 78, 7, 87},
},
PreCommitMessage: nil,
2020-02-27 21:45:31 +00:00
Seed: api.SealSeed{},
CommitMessage: nil,
FaultReportMsg: nil,
LastErr: "hi",
}
b, err := cborutil.Dump(si)
if err != nil {
t.Fatal(err)
}
var si2 SectorInfo
if err := cborutil.ReadCborRPC(bytes.NewReader(b), &si); err != nil {
return
}
assert.Equal(t, si.State, si2.State)
assert.Equal(t, si.Nonce, si2.Nonce)
assert.Equal(t, si.SectorID, si2.SectorID)
assert.Equal(t, si.Pieces, si2.Pieces)
assert.Equal(t, si.CommD, si2.CommD)
assert.Equal(t, si.Ticket, si2.Ticket)
assert.Equal(t, si, si2)
}