lotus/types_test.go
laser 9b29210dce remove all lotus types from sealing package in preparation for extraction
events adapter

implement StateWaitMsg and StateComputeDataCommitment

implement StateGetSectorPreCommitOnChainInfo

implement ChainHead and SendMsg

implement remaining methods
2020-04-06 12:57:55 -07:00

63 lines
1.3 KiB
Go

package sealing
import (
"bytes"
"testing"
"gotest.tools/assert"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
)
func TestSectorInfoSelialization(t *testing.T) {
d := abi.DealID(1234)
dummyCid := builtin.AccountActorCodeID
si := &SectorInfo{
State: "stateful",
SectorID: 234,
Nonce: 345,
Pieces: []Piece{{
DealID: &d,
Size: 5,
CommP: dummyCid,
}},
CommD: &dummyCid,
CommR: nil,
Proof: nil,
TicketValue: []byte{87, 78, 7, 87},
TicketEpoch: 345,
PreCommitMessage: nil,
SeedValue: []byte{},
SeedEpoch: 0,
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.TicketValue, si2.TicketValue)
assert.Equal(t, si.TicketEpoch, si2.TicketEpoch)
assert.Equal(t, si, si2)
}