Some test fixes

This commit is contained in:
Łukasz Magiera 2020-02-26 10:05:22 +01:00
parent 1b6646b55a
commit cb09e48e8c
7 changed files with 33 additions and 23 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"testing"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/stretchr/testify/require"
)
@ -14,7 +15,7 @@ func (ts *testSuite) testMining(t *testing.T) {
h1, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, uint64(0), h1.Height())
require.Equal(t, abi.ChainEpoch(0), h1.Height())
newHeads, err := api.ChainNotify(ctx)
require.NoError(t, err)
@ -27,5 +28,5 @@ func (ts *testSuite) testMining(t *testing.T) {
h2, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, uint64(1), h2.Height())
require.Equal(t, abi.ChainEpoch(1), h2.Height())
}

View File

@ -10,7 +10,7 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
@ -27,7 +27,7 @@ func TestMultiSigCreate(t *testing.T) {
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.MultisigCodeCid,
ret, _ := h.CreateActor(t, creatorAddr, builtin.MultisigActorCodeID,
&samsig.ConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},
NumApprovalsThreshold: 2,
@ -53,7 +53,7 @@ func TestMultiSigOps(t *testing.T) {
HarnessAddr(&sig1Addr, 100000),
HarnessAddr(&sig2Addr, 100000),
HarnessAddr(&outsideAddr, 100000),
HarnessActor(&multSigAddr, &creatorAddr, actors.MultisigCodeCid,
HarnessActor(&multSigAddr, &creatorAddr, builtin.MultisigActorCodeID,
func() cbg.CBORMarshaler {
return &samsig.ConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},

View File

@ -5,6 +5,9 @@ import (
"testing"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
@ -18,14 +21,14 @@ func TestPaychCreate(t *testing.T) {
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.PaymentChannelCodeCid,
&actors.PCAConstructorParams{
ret, _ := h.CreateActor(t, creatorAddr, builtin.PaymentChannelActorCodeID,
&paych.ConstructorParams{
To: targetAddr,
})
ApplyOK(t, ret)
}
func signVoucher(t *testing.T, w *wallet.Wallet, addr address.Address, sv *types.SignedVoucher) {
func signVoucher(t *testing.T, w *wallet.Wallet, addr address.Address, sv *paych.SignedVoucher) {
vb, err := sv.SigningBytes()
if err != nil {
t.Fatal(err)
@ -47,8 +50,8 @@ func TestPaychUpdate(t *testing.T) {
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.PaymentChannelCodeCid,
&actors.PCAConstructorParams{
ret, _ := h.CreateActor(t, creatorAddr, builtin.PaymentChannelActorCodeID,
&paych.ConstructorParams{
To: targetAddr,
})
ApplyOK(t, ret)
@ -60,18 +63,18 @@ func TestPaychUpdate(t *testing.T) {
ret, _ = h.SendFunds(t, creatorAddr, pch, types.NewInt(5000))
ApplyOK(t, ret)
sv := &types.SignedVoucher{
sv := &paych.SignedVoucher{
Amount: types.NewInt(100),
Nonce: 1,
}
signVoucher(t, h.w, creatorAddr, sv)
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.UpdateChannelState, &actors.PCAUpdateChannelStateParams{
ret, _ = h.Invoke(t, targetAddr, pch, uint64(builtin.MethodsPaych.UpdateChannelState), &paych.UpdateChannelStateParams{
Sv: *sv,
})
ApplyOK(t, ret)
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.GetToSend, nil)
ret, _ = h.Invoke(t, targetAddr, pch, builtin.MethodsPaych.GetToSend, nil)
ApplyOK(t, ret)
bi := types.BigFromBytes(ret.Return)
@ -79,13 +82,15 @@ func TestPaychUpdate(t *testing.T) {
t.Fatal("toSend amount was wrong: ", bi.String())
}
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.Close, nil)
// TODO settle
ret, _ = h.Invoke(t, targetAddr, pch, uint64(builtin.MethodsPaych.Settle), nil)
ApplyOK(t, ret)
// now we have to 'wait' for the chain to advance.
h.BlockHeight = 1000
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.Collect, nil)
ret, _ = h.Invoke(t, targetAddr, pch, uint64(builtin.MethodsPaych.Settle), nil)
ApplyOK(t, ret)
h.AssertBalanceChange(t, targetAddr, 100)

View File

@ -29,8 +29,8 @@ func TestTsCache(t *testing.T) {
ParentStateRoot: dummyCid,
Messages: dummyCid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: types.Signature{Type: crypto.SigTypeBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS},
}})
if err != nil {
t.Fatal(err)
@ -71,8 +71,8 @@ func TestTsCacheNulls(t *testing.T) {
ParentStateRoot: dummyCid,
Messages: dummyCid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: types.Signature{Type: crypto.SigTypeBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS},
}})
if err != nil {
t.Fatal(err)

View File

@ -10,6 +10,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
blockstore "github.com/ipfs/go-ipfs-blockstore"
)
@ -61,7 +62,7 @@ func BenchmarkGetRandomness(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := cs.GetRandomness(context.TODO(), last.Cids(), 500)
_, err := cs.GetRandomness(context.TODO(), last.Cids(), crypto.DomainSeparationTag_SealRandomness, 500, nil)
if err != nil {
b.Fatal(err)
}

View File

@ -113,7 +113,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
for len(allToSync) > 0 {
actors := map[address.Address]map[types.Actor]actorInfo{}
addresses := map[address.Address]address.Address{}
minH := abi.ChainEpoch(math.MaxUint64)
minH := abi.ChainEpoch(math.MaxInt64)
for _, header := range allToSync {
if header.Height < minH {
@ -123,7 +123,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
toSync := map[cid.Cid]*types.BlockHeader{}
for c, header := range allToSync {
if header.Height < minH+uint64(maxBatch) {
if header.Height < minH+abi.ChainEpoch(maxBatch) {
toSync[c] = header
addresses[header.Miner] = address.Undef
}

View File

@ -4,18 +4,21 @@ import (
"bytes"
"testing"
"github.com/filecoin-project/specs-actors/actors/abi"
"gotest.tools/assert"
"github.com/filecoin-project/go-cbor-util"
)
func TestSectorInfoSelialization(t *testing.T) {
d := abi.DealID(1234)
si := &SectorInfo{
State: 123,
SectorID: 234,
Nonce: 345,
Pieces: []Piece{{
DealID: 1234,
DealID: &d,
Size: 5,
CommP: []byte{3},
}},