lotus/itests/kit/funds.go

40 lines
918 B
Go
Raw Normal View History

2021-05-18 21:01:10 +00:00
package kit
import (
"context"
"testing"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-address"
2021-05-20 15:12:42 +00:00
"github.com/filecoin-project/lotus/api"
2021-05-18 21:01:10 +00:00
"github.com/filecoin-project/lotus/chain/types"
)
2021-05-20 15:12:42 +00:00
// SendFunds sends funds from the default wallet of the specified sender node
// to the recipient address.
func SendFunds(ctx context.Context, t *testing.T, sender TestFullNode, recipient address.Address, amount abi.TokenAmount) {
2021-05-18 21:01:10 +00:00
senderAddr, err := sender.WalletDefaultAddress(ctx)
if err != nil {
t.Fatal(err)
}
2021-05-18 21:01:10 +00:00
msg := &types.Message{
From: senderAddr,
2021-05-20 15:12:42 +00:00
To: recipient,
2021-05-18 21:01:10 +00:00
Value: amount,
}
sm, err := sender.MpoolPushMessage(ctx, msg, nil)
if err != nil {
t.Fatal(err)
}
2021-05-20 15:12:42 +00:00
res, err := sender.StateWaitMsg(ctx, sm.Cid(), 3, api.LookbackNoLimit, true)
if err != nil {
t.Fatal(err)
}
if res.Receipt.ExitCode != 0 {
t.Fatal("did not successfully send money")
}
2021-05-18 21:01:10 +00:00
}