diff --git a/internal/orchestrator/txn_status.go b/internal/orchestrator/txn_status.go index 2d0a30f3e7..e6503626f7 100644 --- a/internal/orchestrator/txn_status.go +++ b/internal/orchestrator/txn_status.go @@ -81,6 +81,15 @@ func (or *orchestrator) GetTransactionStatus(ctx context.Context, id string) (*c } for _, op := range ops { result.Details = append(result.Details, txOperationStatus(op)) + if op.Status == core.OpStatusPending { + // Check to see if there's an update + // Operations can stay in "Pending" if FireFly was down when a TX receipt became available + opWithDetail, err := or.GetOperationByIDWithStatus(ctx, op.ID.String()) + if err != nil { + return nil, err + } + op = &opWithDetail.Operation + } if op.Retry == nil { updateStatus(result, op.Status) } diff --git a/internal/orchestrator/txn_status_test.go b/internal/orchestrator/txn_status_test.go index b01e31fcd9..8aedb21e57 100644 --- a/internal/orchestrator/txn_status_test.go +++ b/internal/orchestrator/txn_status_test.go @@ -650,6 +650,9 @@ func TestGetTransactionStatusTokenTransferRetry(t *testing.T) { or.mth.On("GetTransactionByIDCached", mock.Anything, txID).Return(tx, nil) or.mdi.On("GetOperations", mock.Anything, "ns", mock.Anything).Return(ops, nil, nil) + or.mom.On("GetOperationByIDCached", mock.Anything, op1ID).Return(ops[0], nil) + or.mom.On("GetOperationByIDCached", mock.Anything, op2ID).Return(ops[1], nil) + or.mbi.On("GetTransactionStatus", mock.Anything, mock.Anything).Return(nil, nil) or.mdi.On("GetBlockchainEvents", mock.Anything, "ns", mock.Anything).Return(events, nil, nil) or.mdi.On("GetTokenTransfers", mock.Anything, "ns", mock.Anything).Return(transfers, nil, nil) @@ -940,3 +943,29 @@ func TestGetTransactionStatusUnknownType(t *testing.T) { or.mdi.AssertExpectations(t) } + +func TestGetTransactionStatusOpStatusError(t *testing.T) { + or := newTestOrchestrator() + + txID := fftypes.NewUUID() + tx := &core.Transaction{ + Namespace: "ns1", + Type: core.TransactionTypeTokenTransfer, + } + op1ID := fftypes.NewUUID() + ops := []*core.Operation{ + { + Namespace: "ns1", + Status: core.OpStatusPending, + ID: op1ID, + Type: core.OpTypeTokenTransfer, + }, + } + + or.mth.On("GetTransactionByIDCached", mock.Anything, txID).Return(tx, nil) + or.mdi.On("GetOperations", mock.Anything, "ns", mock.Anything).Return(ops, nil, nil) + or.mom.On("GetOperationByIDCached", mock.Anything, op1ID).Return(nil, fmt.Errorf("pop")) + + _, err := or.GetTransactionStatus(context.Background(), txID.String()) + assert.EqualError(t, err, "pop") +}