Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
storage power actor tests (#56)
Browse files Browse the repository at this point in the history
* add storage power types and gen
* add storage power tests
* add id to address mapping method to message producer
* remove unused peerid type
* cbor gen update
  • Loading branch information
frrist authored Dec 10, 2019
1 parent f0e8d9d commit 5153079
Show file tree
Hide file tree
Showing 15 changed files with 853 additions and 72 deletions.
24 changes: 17 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ go 1.13

require (
github.com/filecoin-project/filecoin-ffi v0.0.0-20191204125133-ebb3e13addf1
github.com/ipfs/go-cid v0.0.3
github.com/filecoin-project/go-amt-ipld v0.0.0-20191205011053-79efc22d6cdc
github.com/gogo/protobuf v1.3.1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/ipfs/go-cid v0.0.4-0.20191112011718-79e75dffeb10
github.com/ipfs/go-datastore v0.1.0
github.com/ipfs/go-hamt-ipld v0.0.12-0.20190910032255-ee6e898f0456
github.com/ipfs/go-ipfs-blockstore v0.1.0
github.com/ipfs/go-ipld-cbor v0.0.3
github.com/ipfs/go-ipld-format v0.0.2 // indirect
github.com/libp2p/go-libp2p-core v0.0.2
github.com/ipfs/go-log v1.0.0 // indirect
github.com/libp2p/go-libp2p-core v0.2.4
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/minio/sha256-simd v0.1.0 // indirect
github.com/multiformats/go-multihash v0.0.5
github.com/multiformats/go-multihash v0.0.9
github.com/multiformats/go-varint v0.0.1
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992
github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a
github.com/smartystreets/assertions v1.0.1 // indirect
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
github.com/stretchr/testify v1.4.0
github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d
golang.org/x/sys v0.0.0-20190524122548-abf6ff778158 // indirect
github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20191208220313-d43e400b4942
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 // indirect
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
)
175 changes: 155 additions & 20 deletions go.sum

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions pkg/chain/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ func (mp *MessageProducer) BuildFull(from, to address.Address, method MethodID,
return fm, nil
}

//
// Helper methods until spec defines these
//

func (mp *MessageProducer) SingletonAddress(id actors.SingletonActorID) address.Address {
return mp.factory.FromSingletonAddress(id)
}

func (mp *MessageProducer) ActorCid(c actors.ActorCodeID) cid.Cid {
return mp.factory.FromActorCodeCid(c)
}

//
// Sugar methods for type-checked construction of specific messages.
//
Expand Down Expand Up @@ -230,6 +242,24 @@ func (mp *MessageProducer) StoragePowerUpdateStorage(from address.Address, nonce
return mp.Build(from, spaAddr, nonce, StoragePowerUpdatePower, params, opts...)
}

func (mp *MessageProducer) StoragePowerPledgeCollateralForSize(from address.Address, nonce uint64, size types.BigInt, opts ...MsgOpt) (interface{}, error) {
params, err := types.Serialize(&strgpwr.PledgeCollateralParams{Size: size})
if err != nil {
return nil, err
}
spaAddr := mp.factory.FromSingletonAddress(actors.StoragePowerAddress)
return mp.Build(from, spaAddr, nonce, StoragePowerUpdatePower, params, opts...)
}

func (mp *MessageProducer) StoragePowerLookupPower(from address.Address, nonce uint64, miner address.Address, opts ...MsgOpt) (interface{}, error) {
params, err := types.Serialize(&strgpwr.PowerLookupParams{Miner: miner})
if err != nil {
return nil, err
}
spaAddr := mp.factory.FromSingletonAddress(actors.StoragePowerAddress)
return mp.Build(from, spaAddr, nonce, StoragePowerUpdatePower, params, opts...)
}

//
// Storage Miner Actor Methods
//
Expand Down
3 changes: 3 additions & 0 deletions pkg/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func main() {
if err := gen.WriteTupleEncodersToFile("../state/actors/strgpwr/cbor_gen.go", "strgpwr",
strgpwr.CreateStorageMinerParams{},
strgpwr.UpdateStorageParams{},
strgpwr.StoragePowerState{},
strgpwr.PledgeCollateralParams{},
strgpwr.PowerLookupParams{},
); err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/state/actors/initialize/cbor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (t *ExecParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand Down
24 changes: 14 additions & 10 deletions pkg/state/actors/multsig/cbor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.Signers: array too large (%d)", extra)
}

Expand Down Expand Up @@ -165,7 +166,8 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.Transactions: array too large (%d)", extra)
}

Expand Down Expand Up @@ -326,10 +328,10 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand All @@ -343,7 +345,8 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.Approved: array too large (%d)", extra)
}

Expand Down Expand Up @@ -506,7 +509,8 @@ func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.Signers: array too large (%d)", extra)
}

Expand Down Expand Up @@ -741,10 +745,10 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand Down
27 changes: 14 additions & 13 deletions pkg/state/actors/paych/cbor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}

Expand Down Expand Up @@ -510,10 +511,10 @@ func (t *PaymentChannelUpdateParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Secret: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Secret: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand All @@ -527,10 +528,10 @@ func (t *PaymentChannelUpdateParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand Down Expand Up @@ -589,10 +590,10 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Extra: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Extra: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand All @@ -606,10 +607,10 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/state/actors/strgminr/cbor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.CommR: array too large (%d)", extra)
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.CommR: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand All @@ -531,7 +531,8 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {

if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}

Expand Down
Loading

0 comments on commit 5153079

Please sign in to comment.