Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDFSOF-123: End2End tests for SEP-31 and sync with develop #1076

Merged

Conversation

rkharevych
Copy link
Contributor

@rkharevych rkharevych commented Aug 31, 2023

Description

  • End2End tests for SEP-31 flow
  • Sync with develop branch

Testing

  1. ./gradlew test
  2. CUSTODY_TYPE=fireblocks CUSTODY_FIREBLOCKS_VAULT_ACCOUNT_ID=<your_value> SECRET_CUSTODY_FIREBLOCKS_API_KEY=<your_value> SECRET_CUSTODY_FIREBLOCKS_SECRET_KEY=<your_value> ./gradlew clean testFireblocksE2E

rkharevych and others added 9 commits August 21, 2023 18:55
### What

Renaming of RPC actions to RPC requests/methods

### Why

Request/method is more general term than action
…tellar-anchor-sdk into fireblocks_integration
…to pending_anchor/pending_received when the stellar transction with requested memo and amount completed on the network (#17)

### What

Find transaction by `toAccount` + `memo` combination to handle payment

### Why

`SEP-31` payments are not handled correctly
…tellar-anchor-sdk into fireblocks_integration
### What

Validation for deposit info generator type

### Why

If custody integration is enabled, then only `custody` type should be available.
If custody integration is disabled, then `custody` type should be not available.
### Description

End2End tests for SEP-31

### Context

There are no End2End tests for SEP-31
@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

@rkharevych
Copy link
Contributor Author

rkharevych commented Aug 31, 2023

Hi, @Ifropc

It looks like the validation of callbacks is invalid in End2End tests and callbacks themselves also work partially incorrectly.
There are 2 main problems, that can be reproduced in tests very often:

  • duplicates of callback requests;
  • some callback requests are missing.

Tests don't fail, because code, that should assert the error, is not executed, since waitForWalletServerCallbacks returns null. It returns null because the expected number of callbacks is 5 and the actual number is different due to the problems, that I described above. Validation of events works fine:
image
image

We also added code to validate callbacks in our new End2End test for custody/RPC/SEP-31, but commented it and left TODOs to investigate this problem.

In the examples below, there are 4 events, but 8 callbacks(with duplicates and some requests are missing).

Example of events:

[
  {
    "type": "transaction_created",
    "id": "6b410e08-6721-4e6b-9cec-dac9cb0588d4",
    "sep": "24",
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "sep": "24",
      "kind": "deposit",
      "status": "incomplete",
      "amount_expected": {
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "started_at": "2023-08-31T12:10:03.011249Z",
      "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "type": "transaction_status_changed",
    "id": "998cc42e-f6b8-45fd-8c02-2ff241b94773",
    "sep": "24",
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "sep": "24",
      "kind": "deposit",
      "status": "pending_user_transfer_start",
      "amount_expected": {
        "amount": "1.1",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_in": {
        "amount": "1.1",
        "asset": "iso4217:USD"
      },
      "amount_out": {
        "amount": "1.0",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_fee": {
        "amount": "0.1",
        "asset": "iso4217:USD"
      },
      "started_at": "2023-08-31T12:10:03.011249Z",
      "updated_at": "2023-08-31T12:10:05.264005Z",
      "message": "waiting on the user to transfer funds",
      "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "type": "transaction_status_changed",
    "id": "2b05d192-f174-415e-aa99-77a5a4a34624",
    "sep": "24",
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "sep": "24",
      "kind": "deposit",
      "status": "pending_anchor",
      "amount_expected": {
        "amount": "1.1",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_in": {
        "amount": "1.1",
        "asset": "iso4217:USD"
      },
      "amount_out": {
        "amount": "1.0",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_fee": {
        "amount": "0.1",
        "asset": "iso4217:USD"
      },
      "started_at": "2023-08-31T12:10:03.011249Z",
      "updated_at": "2023-08-31T12:10:06.495099Z",
      "message": "funds received, transaction is being processed",
      "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "type": "transaction_status_changed",
    "id": "6755b1e0-7a5f-4137-b0b1-ca748a1b70fa",
    "sep": "24",
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "sep": "24",
      "kind": "deposit",
      "status": "completed",
      "amount_expected": {
        "amount": "1.1",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_in": {
        "amount": "1.1",
        "asset": "iso4217:USD"
      },
      "amount_out": {
        "amount": "1.0",
        "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
      },
      "amount_fee": {
        "amount": "0.1",
        "asset": "iso4217:USD"
      },
      "started_at": "2023-08-31T12:10:03.011249Z",
      "updated_at": "2023-08-31T12:10:14.342682Z",
      "completed_at": "2023-08-31T12:10:14.342689Z",
      "message": "funds received, transaction is being processed",
      "stellar_transactions": [
        {
          "id": "78639da07629ee6863b2fd9f00a56b24e916d36f2a9efb04150ba09236fde067",
          "created_at": "2023-08-31T12:10:12Z",
          "envelope": "AAAAAgAAAAACJQsPAYY4MkKbJBd8Wl742m73Fb648rWVhCuwCcbDzAAAAGQAACDKAAAkWQAAAAEAAAAAAAAAAAAAAABk8INcAAAAAAAAAAEAAAAAAAAAAQAAAADSsOMKYK7a1aALie83F4GQDoBdHrW86UX2SYVygRA+VQAAAAFVU0RDAAAAAODia2IsqMlWCuY6k734V/dcCafJwfI1Qq7+/0qEd68AAAAAAACn2MAAAAAAAAAAAQnGw8wAAABA5850B58//TjHlJKdFTmLSQpdLsF+cx9e7e78VykJhS9a/51w9rV6VO2XOR1EKA+MXFKfNYm9ogAaftlY5v+ECw==",
          "payments": [
            {
              "id": "5516962801131521",
              "amount": {
                "amount": "1.1000000",
                "asset": "USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
              },
              "payment_type": "payment",
              "source_account": "GABCKCYPAGDDQMSCTMSBO7C2L34NU3XXCW7LR4VVSWCCXMAJY3B4YCZP",
              "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
            }
          ]
        }
      ],
      "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  }
]

Example of callbacks:

[
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "incomplete",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDQsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.PsFFYs7Bv6WR2r7a3mD8x9c_xGwMnEsXMcslDmiAoM4",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "incomplete",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDQsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.PsFFYs7Bv6WR2r7a3mD8x9c_xGwMnEsXMcslDmiAoM4",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "incomplete",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDYsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.rtUde3d2YMscWzwIPkh8AMdcDyu8ISCPkuaiSfv8NI0",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "incomplete",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDYsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.rtUde3d2YMscWzwIPkh8AMdcDyu8ISCPkuaiSfv8NI0",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "pending_anchor",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDcsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.FutHYt5x-AyIrN5xKX1rShFlpr7EE_67jom_9O1HItQ",
      "amount_in": "1.1",
      "amount_in_asset": "iso4217:USD",
      "amount_out": "1.0",
      "amount_out_asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
      "amount_fee": "0.1",
      "amount_fee_asset": "iso4217:USD",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "message": "funds received, transaction is being processed",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "pending_user_transfer_start",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MDcsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.FutHYt5x-AyIrN5xKX1rShFlpr7EE_67jom_9O1HItQ",
      "amount_in": "1.1",
      "amount_in_asset": "iso4217:USD",
      "amount_out": "1.0",
      "amount_out_asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
      "amount_fee": "0.1",
      "amount_fee_asset": "iso4217:USD",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "message": "waiting on the user to transfer funds",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "pending_anchor",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MTUsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.Jkh4mqdA6DybJNPXD8qEk-nd78HFag5hxg2yEavD-Yw",
      "amount_in": "1.1",
      "amount_in_asset": "iso4217:USD",
      "amount_out": "1.0",
      "amount_out_asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
      "amount_fee": "0.1",
      "amount_fee_asset": "iso4217:USD",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "message": "funds received, transaction is being processed",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  },
  {
    "transaction": {
      "id": "95e6efdd-38e9-4f93-a98d-53433b0fa75e",
      "kind": "deposit",
      "status": "pending_anchor",
      "more_info_url": "http://localhost:8091/sep24/transaction/more_info?transaction_id=95e6efdd-38e9-4f93-a98d-53433b0fa75e&token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5NWU2ZWZkZC0zOGU5LTRmOTMtYTk4ZC01MzQzM2IwZmE3NWUiLCJleHAiOjE2OTM0ODQ0MTUsInN1YiI6IkdESkxCWVlLTUNYTlZWTkFCT0U2Nk5ZWFFHSUE1QUM1RDIyM1oyS0Y2WkVZSzRVQkNBN0ZLTFRHIiwiZGF0YSI6e30sImNsaWVudF9uYW1lIjoicmVmZXJlbmNlQ3VzdG9kaWFsIn0.Jkh4mqdA6DybJNPXD8qEk-nd78HFag5hxg2yEavD-Yw",
      "amount_in": "1.1",
      "amount_in_asset": "iso4217:USD",
      "amount_out": "1.0",
      "amount_out_asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
      "amount_fee": "0.1",
      "amount_fee_asset": "iso4217:USD",
      "started_at": "2023-08-31T12:10:03.011249Z",
      "message": "funds received, transaction is being processed",
      "refunded": false,
      "to": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
    }
  }
]


@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

expectedEvents: List<AnchorEvent>,
actualEvents: List<AnchorEvent>
) {
expectedEvents.forEachIndexed { index, expectedEvent ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we modify expectedEvent before comparing it to actualEvent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because some fields are dynamic(for example dates) and can not be specified in expectedEvent. The same logic is used in existing End2End tests - Sep24End2EndTests

actualEvent.transaction.amountIn?.let {
expectedEvent.transaction.amountIn.amount = actualEvent.transaction.amountIn.amount
expectedEvent.transaction.amountIn.asset = asset.sep38
// expectedEvent.transaction.amountIn.asset =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some fileds assignment is commented-out, is it expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this commented code

)
}
} catch (e: ClientException) {
log.error(e)
call.respond(ErrorResponse(e.message!!))
call.respond(MessageResponse(e.message!!))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ErrorRespond was changed to MessageRespond in places where exceptions are caught?

Copy link
Contributor Author

@rkharevych rkharevych Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was renamed from ErrorResponse to MessageResponse just because it has a field called msg and I wanted to add a new error response with error field. But now it looks like it is redundant, so I will use only the old ErrorResponse

@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

@stellar-jenkins
Copy link

Reference Server Preview is available here:
https://anchor-ref-pr1076.previews.kube001.services.stellar-ops.com/
SEP Server Preview is available here:
https://anchor-sep-pr1076.previews.kube001.services.stellar-ops.com/

…tellar-anchor-sdk into fireblocks_integration

# Conflicts:
#	platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt
@JakeUrban JakeUrban merged commit 52014ed into stellar:softserve-develop Sep 7, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants