2020-01-15 20:49:11 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/assert"
|
|
|
|
|
2020-02-27 00:42:39 +00:00
|
|
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
2020-04-06 18:07:26 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-01-15 20:49:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSectorInfoSelialization(t *testing.T) {
|
2020-02-26 09:05:22 +00:00
|
|
|
d := abi.DealID(1234)
|
|
|
|
|
2020-04-07 21:44:33 +00:00
|
|
|
dealInfo := DealInfo{
|
|
|
|
DealID: d,
|
|
|
|
DealSchedule: DealSchedule{
|
|
|
|
StartEpoch: 0,
|
|
|
|
EndEpoch: 100,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:42:39 +00:00
|
|
|
dummyCid := builtin.AccountActorCodeID
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
si := &SectorInfo{
|
2020-04-06 22:31:33 +00:00
|
|
|
State: "stateful",
|
|
|
|
SectorNumber: 234,
|
2020-04-08 14:52:20 +00:00
|
|
|
Pieces: []Piece{{
|
2020-04-07 21:44:33 +00:00
|
|
|
Piece: abi.PieceInfo{
|
|
|
|
Size: 5,
|
|
|
|
PieceCID: dummyCid,
|
|
|
|
},
|
|
|
|
DealInfo: &dealInfo,
|
2020-01-15 20:49:11 +00:00
|
|
|
}},
|
2020-04-06 18:07:26 +00:00
|
|
|
CommD: &dummyCid,
|
|
|
|
CommR: nil,
|
|
|
|
Proof: nil,
|
|
|
|
TicketValue: []byte{87, 78, 7, 87},
|
|
|
|
TicketEpoch: 345,
|
2020-01-15 20:49:11 +00:00
|
|
|
PreCommitMessage: nil,
|
2020-04-06 18:07:26 +00:00
|
|
|
SeedValue: []byte{},
|
|
|
|
SeedEpoch: 0,
|
2020-01-15 20:49:11 +00:00
|
|
|
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)
|
2020-04-06 22:31:33 +00:00
|
|
|
assert.Equal(t, si.SectorNumber, si2.SectorNumber)
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2020-04-08 14:52:20 +00:00
|
|
|
assert.Equal(t, si.Pieces, si2.Pieces)
|
2020-01-15 20:49:11 +00:00
|
|
|
assert.Equal(t, si.CommD, si2.CommD)
|
2020-04-06 18:07:26 +00:00
|
|
|
assert.Equal(t, si.TicketValue, si2.TicketValue)
|
|
|
|
assert.Equal(t, si.TicketEpoch, si2.TicketEpoch)
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
assert.Equal(t, si, si2)
|
|
|
|
|
|
|
|
}
|