2020-01-15 20:49:11 +00:00
|
|
|
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"
|
2020-01-15 20:49:11 +00:00
|
|
|
"gotest.tools/assert"
|
|
|
|
|
2020-02-27 00:42:39 +00:00
|
|
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
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-02-27 00:42:39 +00:00
|
|
|
dummyCid := builtin.AccountActorCodeID
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
si := &SectorInfo{
|
|
|
|
State: 123,
|
|
|
|
SectorID: 234,
|
|
|
|
Nonce: 345,
|
|
|
|
Pieces: []Piece{{
|
2020-02-26 09:05:22 +00:00
|
|
|
DealID: &d,
|
2020-01-15 20:49:11 +00:00
|
|
|
Size: 5,
|
2020-02-27 00:42:39 +00:00
|
|
|
CommP: dummyCid,
|
2020-01-15 20:49:11 +00:00
|
|
|
}},
|
2020-02-27 00:42:39 +00:00
|
|
|
CommD: &dummyCid,
|
2020-01-15 20:49:11 +00:00
|
|
|
CommR: nil,
|
|
|
|
Proof: nil,
|
2020-02-27 21:45:31 +00:00
|
|
|
Ticket: api.SealTicket{
|
|
|
|
Epoch: 345,
|
|
|
|
Value: []byte{87, 78, 7, 87},
|
2020-01-15 20:49:11 +00:00
|
|
|
},
|
|
|
|
PreCommitMessage: nil,
|
2020-02-27 21:45:31 +00:00
|
|
|
Seed: api.SealSeed{},
|
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)
|
|
|
|
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)
|
|
|
|
|
|
|
|
}
|