From 8dc49447ad8709c37afe105134525fd3854cf98e Mon Sep 17 00:00:00 2001 From: Travis Person <165274+travisperson@users.noreply.github.com> Date: Fri, 3 May 2019 17:38:33 -0700 Subject: [PATCH] FAST: SendFilecoinFromDefault returns mcid (#2686) --- tools/fast/series/send_filecoin_defaults.go | 14 ++++++++++++-- tools/fast/series/send_filecoin_from_default.go | 14 +++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/fast/series/send_filecoin_defaults.go b/tools/fast/series/send_filecoin_defaults.go index bc7db3ef80..25990c9e8d 100644 --- a/tools/fast/series/send_filecoin_defaults.go +++ b/tools/fast/series/send_filecoin_defaults.go @@ -8,12 +8,22 @@ import ( ) // SendFilecoinDefaults sends the `value` amount of fil from the default wallet -// address of the `from` node to the `to` node's default wallet. +// address of the `from` node to the `to` node's default wallet, and waits for the +// message to be received by the `to` node. func SendFilecoinDefaults(ctx context.Context, from, to *fast.Filecoin, value int) error { var toAddr address.Address if err := to.ConfigGet(ctx, "wallet.defaultAddress", &toAddr); err != nil { return err } - return SendFilecoinFromDefault(ctx, from, toAddr, value) + mcid, err := SendFilecoinFromDefault(ctx, from, toAddr, value) + if err != nil { + return err + } + + if _, err := to.MessageWait(ctx, mcid); err != nil { + return err + } + + return nil } diff --git a/tools/fast/series/send_filecoin_from_default.go b/tools/fast/series/send_filecoin_from_default.go index 4810a63b61..5a17de660d 100644 --- a/tools/fast/series/send_filecoin_from_default.go +++ b/tools/fast/series/send_filecoin_from_default.go @@ -4,6 +4,8 @@ import ( "context" "math/big" + "github.com/ipfs/go-cid" + "github.com/filecoin-project/go-filecoin/address" "github.com/filecoin-project/go-filecoin/tools/fast" ) @@ -11,22 +13,24 @@ import ( // SendFilecoinFromDefault will send the `value` of FIL from the default wallet // address, per the config of the `node`, to the provided address `addr` and // wait for the message to showup on chain. -func SendFilecoinFromDefault(ctx context.Context, node *fast.Filecoin, addr address.Address, value int) error { +// The waiting node is the sender, this does not guarantee that the message has +// been received by the targeted node of addr. +func SendFilecoinFromDefault(ctx context.Context, node *fast.Filecoin, addr address.Address, value int) (cid.Cid, error) { var walletAddr address.Address if err := node.ConfigGet(ctx, "wallet.defaultAddress", &walletAddr); err != nil { - return err + return cid.Undef, err } mcid, err := node.MessageSend(ctx, addr, "", fast.AOValue(value), fast.AOFromAddr(walletAddr), fast.AOPrice(big.NewFloat(1.0)), fast.AOLimit(300)) if err != nil { - return err + return cid.Undef, err } CtxMiningOnce(ctx) if _, err := node.MessageWait(ctx, mcid); err != nil { - return err + return cid.Undef, err } - return nil + return mcid, nil }