Skip to content

Commit

Permalink
fixed WaitForTransactionReceipt error handling and revert TestWaitFor…
Browse files Browse the repository at this point in the history
…TransactionReceipt changes
  • Loading branch information
thiagodeev committed May 17, 2024
1 parent a018e9f commit d6c9450
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ func (account *Account) WaitForTransactionReceipt(ctx context.Context, transacti
case <-t.C:
receiptWithBlockInfo, err := account.TransactionReceipt(ctx, transactionHash)
if err != nil {
if errors.Is(err, rpc.ErrHashNotFound) {
rpcErr := err.(*rpc.RPCError)
if rpcErr.Code == rpc.ErrHashNotFound.Code && rpcErr.Message == rpc.ErrHashNotFound.Message {
continue
} else {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
testSet := map[string][]testSetType{
"devnet": {
{
Timeout: 1, // Should poll 3 times
Timeout: 3, // Should poll 3 times
Hash: new(felt.Felt).SetUint64(100),
ExpectedReceipt: nil,
ExpectedErr: rpc.Err(rpc.InternalError, "Post \"http://0.0.0.0:5050/\": context deadline exceeded"),
Expand All @@ -1131,7 +1131,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(test.Timeout)*time.Second)
defer cancel()

resp, err := acnt.WaitForTransactionReceipt(ctx, test.Hash, 2*time.Second)
resp, err := acnt.WaitForTransactionReceipt(ctx, test.Hash, 1*time.Second)
if test.ExpectedErr != nil {
require.Equal(t, test.ExpectedErr.Error(), err.Error())
} else {
Expand Down

0 comments on commit d6c9450

Please sign in to comment.