Skip to content

Commit

Permalink
itests: Some kit cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jul 7, 2021
1 parent d0e87a7 commit 9bdea91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion itests/deals_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestPublishDealsBatching(t *testing.T) {
_, err = client.WalletImport(ctx, &publisherKey.KeyInfo)
require.NoError(t, err)

kit.SetControlAddresses(t, client, miner, publisherKey.Address)
miner.SetControlAddresses(publisherKey.Address)

dh := kit.NewDealHarness(t, client, miner)

Expand Down
17 changes: 8 additions & 9 deletions itests/kit/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kit

import (
"context"
"testing"

"github.com/stretchr/testify/require"

Expand All @@ -15,29 +14,29 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)

func SetControlAddresses(t *testing.T, client *TestFullNode, w *TestMiner, addrs ...addr.Address) {
func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address) {
ctx := context.TODO()

mi, err := client.StateMinerInfo(ctx, w.ActorAddr, types.EmptyTSK)
require.NoError(t, err)
mi, err := tm.FullNode.StateMinerInfo(ctx, tm.ActorAddr, types.EmptyTSK)
require.NoError(tm.t, err)

cwp := &miner2.ChangeWorkerAddressParams{
NewWorker: mi.Worker,
NewControlAddrs: addrs,
}

sp, err := actors.SerializeParams(cwp)
require.NoError(t, err)
require.NoError(tm.t, err)

smsg, err := client.MpoolPushMessage(ctx, &types.Message{
smsg, err := tm.FullNode.MpoolPushMessage(ctx, &types.Message{
From: mi.Owner,
To: w.ActorAddr,
To: tm.ActorAddr,
Method: miner.Methods.ChangeWorkerAddress,

Value: big.Zero(),
Params: sp,
}, nil)
require.NoError(t, err)
require.NoError(tm.t, err)

WaitMsg(ctx, t, client, smsg.Cid())
tm.FullNode.WaitMsg(ctx, smsg.Cid())
}
10 changes: 5 additions & 5 deletions itests/kit/funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, recipien
sm, err := sender.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err)

WaitMsg(ctx, t, sender, sm.Cid())
sender.WaitMsg(ctx, sm.Cid())
}

func WaitMsg(ctx context.Context, t *testing.T, node *TestFullNode, msg cid.Cid) {
res, err := node.StateWaitMsg(ctx, msg, 3, api.LookbackNoLimit, true)
require.NoError(t, err)
func (f *TestFullNode) WaitMsg(ctx context.Context, msg cid.Cid) {
res, err := f.StateWaitMsg(ctx, msg, 3, api.LookbackNoLimit, true)
require.NoError(f.t, err)

require.EqualValues(t, 0, res.Receipt.ExitCode, "message did not successfully execute")
require.EqualValues(f.t, 0, res.Receipt.ExitCode, "message did not successfully execute")
}

0 comments on commit 9bdea91

Please sign in to comment.