2021-06-18 18:45:29 +00:00
|
|
|
package kit
|
2021-06-11 17:26:25 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2021-06-11 17:26:25 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2021-07-07 17:35:27 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
|
2021-06-11 17:26:25 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SendFunds sends funds from the default wallet of the specified sender node
|
|
|
|
// to the recipient address.
|
2021-06-18 18:23:32 +00:00
|
|
|
func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, recipient address.Address, amount abi.TokenAmount) {
|
2021-06-11 17:26:25 +00:00
|
|
|
senderAddr, err := sender.WalletDefaultAddress(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
From: senderAddr,
|
|
|
|
To: recipient,
|
|
|
|
Value: amount,
|
|
|
|
}
|
|
|
|
|
|
|
|
sm, err := sender.MpoolPushMessage(ctx, msg, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
sender.WaitMsg(ctx, sm.Cid())
|
2021-07-07 17:12:03 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
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)
|
2021-06-11 17:26:25 +00:00
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
require.EqualValues(f.t, 0, res.Receipt.ExitCode, "message did not successfully execute")
|
2021-06-11 17:26:25 +00:00
|
|
|
}
|