From 5c7f419b80d156d73103789ee4e3d3dbb600e986 Mon Sep 17 00:00:00 2001 From: Jiahui Hu Date: Fri, 13 Oct 2023 14:21:27 -0400 Subject: [PATCH] [ANCHOR-487] Skip failing tests that needs anchor config (#124) * skip the failing tests that needs anchor config * add config example to readme --- @stellar/anchor-tests/README.md | 89 +++++++++++++++++++ @stellar/anchor-tests/package.json | 2 +- .../src/tests/sep24/transaction.ts | 44 +++++---- 3 files changed, 110 insertions(+), 25 deletions(-) diff --git a/@stellar/anchor-tests/README.md b/@stellar/anchor-tests/README.md index 74cbcd0..46d1cad 100644 --- a/@stellar/anchor-tests/README.md +++ b/@stellar/anchor-tests/README.md @@ -27,6 +27,8 @@ Options: [array] [required] -v, --verbose Display the each request and response used in each failed test. [boolean] [default: false] + --sep-config Path to a JSON file containing SEP-specific configuration + options. See below for config examples. [string] ``` ``` @@ -59,3 +61,90 @@ const config: Config = { } })() ``` + +### SEP config example + +```json +{ + "12": { + "customers": { + "toBeCreated": { + "first_name": "John", + "last_name": "Doe", + "email_address": "john@email.com", + "bank_number": "123", + "bank_account_number": "456", + "bank_account_type": "checking" + }, + "sendingClient": { + "first_name": "Allie", + "last_name": "Grater", + "email_address": "allie@email.com" + }, + "receivingClient": { + "first_name": "Lee", + "last_name": "Sun", + "email_address": "lee@email.com", + "clabe_number": "1234", + "bank_number": "abcd", + "bank_account_number": "1234", + "bank_account_type": "checking" + }, + "toBeDeleted": { + "first_name": "Jane", + "last_name": "Doe", + "email_address": "jane@email.com" + } + }, + "createCustomer": "toBeCreated", + "deleteCustomer": "toBeDeleted", + "sameAccountDifferentMemos": ["sendingClient", "receivingClient"] + }, + /* + * SEP-24 config is optional for enabling partial tests in transaction. + * Please provide valid input if you plan to do so. + */ + "24": { + "account": { + "publicKey": "", + "secretKey": "" + }, + "depositPendingTransaction": { + "id": "", + "status": "any pending_ status" + }, + "depositCompletedTransaction": { + "id": "", + "status": "completed", + "stellar_transaction_id": "" + }, + "withdrawPendingUserTransferStartTransaction": { + "id": "", + "status": "pending_user_transfer_start", + "amount_in": "222.00", + "amount_in_asset": "", + "withdraw_anchor_account": "", + "withdraw_memo": "", + "withdraw_memo_type": "text" + }, + "withdrawCompletedTransaction": { + "id": "", + "status": "completed", + "stellar_transaction_id": "" + } + }, + "31": { + "sendingAnchorClientSecret": "", + "sendingClientName": "sendingClient", + "receivingClientName": "receivingClient", + "transactionFields": { + "receiver_account_number": "123", + "receiver_routing_number": "456", + "type": "SWIFT" + } + }, + "38": { + "contexts": ["sep31"] + } +} +``` \ No newline at end of file diff --git a/@stellar/anchor-tests/package.json b/@stellar/anchor-tests/package.json index 887f8fe..cfac694 100644 --- a/@stellar/anchor-tests/package.json +++ b/@stellar/anchor-tests/package.json @@ -1,6 +1,6 @@ { "name": "@stellar/anchor-tests", - "version": "0.6.1", + "version": "0.6.2", "description": "stellar-anchor-tests is a library and command line interface for testing Stellar anchors.", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/@stellar/anchor-tests/src/tests/sep24/transaction.ts b/@stellar/anchor-tests/src/tests/sep24/transaction.ts index def8573..da17fd4 100644 --- a/@stellar/anchor-tests/src/tests/sep24/transaction.ts +++ b/@stellar/anchor-tests/src/tests/sep24/transaction.ts @@ -191,10 +191,9 @@ const hasProperPendingDepositTransactionSchema: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field depositPendingTransaction is not present + if (!config.sepConfig?.["24"]?.depositPendingTransaction) { + result.skipped = true; return result; } @@ -273,10 +272,9 @@ const hasProperCompletedDepositTransactionSchema: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field depositCompletedTransaction is not present + if (!config.sepConfig?.["24"]?.depositCompletedTransaction) { + result.skipped = true; return result; } @@ -403,10 +401,11 @@ export const hasProperPendingWithdrawTransactionSchema: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field withdrawPendingUserTransferStartTransaction is not present + if ( + !config.sepConfig?.["24"]?.withdrawPendingUserTransferStartTransaction + ) { + result.skipped = true; return result; } @@ -485,10 +484,9 @@ export const hasProperCompletedWithdrawTransactionSchema: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field withdrawCompletedTransaction is not present + if (!config.sepConfig?.["24"]?.withdrawCompletedTransaction) { + result.skipped = true; return result; } @@ -562,10 +560,9 @@ const returnsDepositTransactionForStellarTxId: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field depositCompletedTransaction is not present + if (!config.sepConfig?.["24"]?.depositCompletedTransaction) { + result.skipped = true; return result; } @@ -631,10 +628,9 @@ const returnsWithdrawTransactionForStellarTxId: Test = { async run(config: Config): Promise { const result: Result = { networkCalls: [] }; - if (!config.sepConfig?.["24"]) { - result.failure = makeFailure(this.failureModes.MISSING_CONFIG, { - sep: "SEP-24", - }); + // Skip this test if SEP-24 config with field depositCompletedTransaction is not present + if (!config.sepConfig?.["24"]?.withdrawCompletedTransaction) { + result.skipped = true; return result; }