some test fixes
This commit is contained in:
parent
d6dffed203
commit
4e98f2e438
@ -7,7 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
xerrors "golang.org/x/xerrors"
|
xerrors "golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
@ -8,6 +8,10 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
@ -69,10 +73,14 @@ func (ta *testActor) Constructor(act *types.Actor, vmctx types.VMContext, params
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
empty, err := vmctx.Storage().Put(&adt.EmptyValue{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("NEW ACTOR ADDRESS IS: ", vmctx.Message().To.String())
|
fmt.Println("NEW ACTOR ADDRESS IS: ", vmctx.Message().To.String())
|
||||||
|
|
||||||
return nil, vmctx.Storage().Commit(actors.EmptyCBOR, c)
|
return nil, vmctx.Storage().Commit(empty, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ta *testActor) TestMethod(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
|
func (ta *testActor) TestMethod(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
|
||||||
@ -114,8 +122,6 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
actors.BuiltInActors[actcid] = true
|
|
||||||
|
|
||||||
// predicting the address here... may break if other assumptions change
|
// predicting the address here... may break if other assumptions change
|
||||||
taddr, err := address.NewIDAddress(1000)
|
taddr, err := address.NewIDAddress(1000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -156,7 +162,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inv.Register(actcid, &testActor{}, &testActorState{})
|
inv.Register(actcid, &testActor{}, &testActorState{})
|
||||||
sm.SetVMConstructor(func(c cid.Cid, h abi.ChainEpoch, r vm.Rand, a address.Address, b blockstore.Blockstore, s *types.VMSyscalls) (*vm.VM, error) {
|
sm.SetVMConstructor(func(c cid.Cid, h abi.ChainEpoch, r vm.Rand, a address.Address, b blockstore.Blockstore, s runtime.Syscalls) (*vm.VM, error) {
|
||||||
nvm, err := vm.NewVM(c, h, r, a, b, s)
|
nvm, err := vm.NewVM(c, h, r, a, b, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -169,7 +175,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
|
|
||||||
var msgs []*types.SignedMessage
|
var msgs []*types.SignedMessage
|
||||||
|
|
||||||
enc, err := actors.SerializeParams(&actors.ExecParams{Code: actcid})
|
enc, err := actors.SerializeParams(&init_.ExecParams{CodeCID: actcid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -177,7 +183,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
m := &types.Message{
|
m := &types.Message{
|
||||||
From: cg.Banker(),
|
From: cg.Banker(),
|
||||||
To: actors.InitAddress,
|
To: actors.InitAddress,
|
||||||
Method: actors.IAMethods.Exec,
|
Method: builtin.MethodsInit.Exec,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
GasLimit: types.NewInt(10000),
|
GasLimit: types.NewInt(10000),
|
||||||
GasPrice: types.NewInt(0),
|
GasPrice: types.NewInt(0),
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
xerrors "golang.org/x/xerrors"
|
xerrors "golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
@ -5,10 +5,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Address(i uint64) address.Address {
|
func Address(i uint64) address.Address {
|
||||||
@ -66,12 +68,12 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
|
|||||||
},
|
},
|
||||||
Parents: pcids,
|
Parents: pcids,
|
||||||
ParentMessageReceipts: c,
|
ParentMessageReceipts: c,
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
|
||||||
ParentWeight: weight,
|
ParentWeight: weight,
|
||||||
Messages: c,
|
Messages: c,
|
||||||
Height: height,
|
Height: height,
|
||||||
ParentStateRoot: c,
|
ParentStateRoot: c,
|
||||||
BlockSig: &types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func Sign(sigType crypto.SigType, privkey []byte, msg []byte) (*crypto.Signature, error) {
|
func Sign(sigType crypto.SigType, privkey []byte, msg []byte) (*crypto.Signature, error) {
|
||||||
sv, ok := sigs[sigType]
|
sv, ok := sigs[sigType]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("cannot sign message with signature of unsupported type: %s", sigType)
|
return nil, fmt.Errorf("cannot sign message with signature of unsupported type: %v", sigType)
|
||||||
}
|
}
|
||||||
|
|
||||||
sb, err := sv.Sign(privkey, msg)
|
sb, err := sv.Sign(privkey, msg)
|
||||||
@ -42,7 +42,7 @@ func Verify(sig *crypto.Signature, addr address.Address, msg []byte) error {
|
|||||||
|
|
||||||
sv, ok := sigs[sig.Type]
|
sv, ok := sigs[sig.Type]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("cannot verify signature of unsupported type: %s", sig.Type)
|
return fmt.Errorf("cannot verify signature of unsupported type: %v", sig.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sv.Verify(sig.Data, addr, msg)
|
return sv.Verify(sig.Data, addr, msg)
|
||||||
@ -52,7 +52,7 @@ func Verify(sig *crypto.Signature, addr address.Address, msg []byte) error {
|
|||||||
func Generate(sigType crypto.SigType) ([]byte, error) {
|
func Generate(sigType crypto.SigType) ([]byte, error) {
|
||||||
sv, ok := sigs[sigType]
|
sv, ok := sigs[sigType]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("cannot generate private key of unsupported type: %s", sigType)
|
return nil, fmt.Errorf("cannot generate private key of unsupported type: %v", sigType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sv.GenPrivate()
|
return sv.GenPrivate()
|
||||||
@ -62,7 +62,7 @@ func Generate(sigType crypto.SigType) ([]byte, error) {
|
|||||||
func ToPublic(sigType crypto.SigType, pk []byte) ([]byte, error) {
|
func ToPublic(sigType crypto.SigType, pk []byte) ([]byte, error) {
|
||||||
sv, ok := sigs[sigType]
|
sv, ok := sigs[sigType]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("cannot generate public key of unsupported type: %s", sigType)
|
return nil, fmt.Errorf("cannot generate public key of unsupported type: %v", sigType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sv.ToPublic(pk)
|
return sv.ToPublic(pk)
|
||||||
|
@ -138,13 +138,13 @@ func (sb *SBMock) SealPreCommit(ctx context.Context, sid abi.SectorNumber, ticke
|
|||||||
ss.lk.Lock()
|
ss.lk.Lock()
|
||||||
defer ss.lk.Unlock()
|
defer ss.lk.Unlock()
|
||||||
|
|
||||||
ussize := abi.UnpaddedPieceSize(sb.sectorSize)
|
ussize := abi.PaddedPieceSize(sb.sectorSize).Unpadded()
|
||||||
|
|
||||||
// TODO: verify pieces in sinfo.pieces match passed in pieces
|
// TODO: verify pieces in sinfo.pieces match passed in pieces
|
||||||
|
|
||||||
var sum abi.UnpaddedPieceSize
|
var sum abi.UnpaddedPieceSize
|
||||||
for _, p := range pieces {
|
for _, p := range pieces {
|
||||||
sum += abi.UnpaddedPieceSize(p.Size)
|
sum += p.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
if sum != ussize {
|
if sum != ussize {
|
||||||
@ -294,7 +294,7 @@ func (sb *SBMock) ReadPieceFromSealedSector(ctx context.Context, sectorID abi.Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) StageFakeData() (abi.SectorNumber, []sectorbuilder.PublicPieceInfo, error) {
|
func (sb *SBMock) StageFakeData() (abi.SectorNumber, []sectorbuilder.PublicPieceInfo, error) {
|
||||||
usize := abi.UnpaddedPieceSize(sb.sectorSize)
|
usize := abi.PaddedPieceSize(sb.sectorSize).Unpadded()
|
||||||
sid, err := sb.AcquireSectorNumber()
|
sid, err := sb.AcquireSectorNumber()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@ -357,7 +357,7 @@ func (m mockVerif) GenerateDataCommitment(ssize abi.PaddedPieceSize, pieces []ff
|
|||||||
if len(pieces) != 1 {
|
if len(pieces) != 1 {
|
||||||
panic("todo")
|
panic("todo")
|
||||||
}
|
}
|
||||||
if pieces[0].Size != abi.UnpaddedPieceSize(ssize) {
|
if pieces[0].Size != ssize.Unpadded() {
|
||||||
panic("todo")
|
panic("todo")
|
||||||
}
|
}
|
||||||
return pieces[0].CommP, nil
|
return pieces[0].CommP, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user