Skip to content

Commit

Permalink
Merge pull request #72 from iotexproject/yutong/longg
Browse files Browse the repository at this point in the history
wait longer
  • Loading branch information
CoderZhi authored Oct 13, 2019
2 parents 1b65c46 + b6c3cfc commit ae58236
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/iotexproject/iotex-antenna-go/v2

require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/ethereum/go-ethereum v1.8.27
github.com/gogo/protobuf v1.2.1
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down
16 changes: 11 additions & 5 deletions utils/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"time"

"github.com/cenkalti/backoff"
"github.com/iotexproject/iotex-antenna-go/v2/iotex"
"github.com/iotexproject/iotex-proto/golang/iotexapi"
"github.com/pkg/errors"
Expand All @@ -18,13 +19,18 @@ func Wait(ctx context.Context, caller iotex.SendActionCaller, opts ...grpc.CallO
if err != nil {
return err
}
time.Sleep(20 * time.Second)

response, err := caller.API().GetReceiptByAction(ctx, &iotexapi.GetReceiptByActionRequest{
ActionHash: hex.EncodeToString(h[:]),
}, opts...)
if err != nil {
time.Sleep(25 * time.Second)

var response *iotexapi.GetReceiptByActionResponse
rerr := backoff.Retry(func() error {
response, err = caller.API().GetReceiptByAction(ctx, &iotexapi.GetReceiptByActionRequest{
ActionHash: hex.EncodeToString(h[:]),
}, opts...)
return err
}, backoff.WithMaxRetries(backoff.NewConstantBackOff(30*time.Second), 3))
if rerr != nil {
return errors.Errorf("execution get receipt timed out: %v", rerr)
}
if response.ReceiptInfo.Receipt.Status != 1 {
return errors.Errorf("execution failed: %x", h)
Expand Down

0 comments on commit ae58236

Please sign in to comment.