Skip to content

Commit

Permalink
[ANCHOR-487] Skip failing tests that needs anchor config (#124)
Browse files Browse the repository at this point in the history
* skip the failing tests that needs anchor config

* add config example to readme
  • Loading branch information
JiahuiWho authored Oct 13, 2023
1 parent f58851c commit 5c7f419
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 25 deletions.
89 changes: 89 additions & 0 deletions @stellar/anchor-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```

```
Expand Down Expand Up @@ -59,3 +61,90 @@ const config: Config = {
}
})()
```

### SEP config example

```json
{
"12": {
"customers": {
"toBeCreated": {
"first_name": "John",
"last_name": "Doe",
"email_address": "[email protected]",
"bank_number": "123",
"bank_account_number": "456",
"bank_account_type": "checking"
},
"sendingClient": {
"first_name": "Allie",
"last_name": "Grater",
"email_address": "[email protected]"
},
"receivingClient": {
"first_name": "Lee",
"last_name": "Sun",
"email_address": "[email protected]",
"clabe_number": "1234",
"bank_number": "abcd",
"bank_account_number": "1234",
"bank_account_type": "checking"
},
"toBeDeleted": {
"first_name": "Jane",
"last_name": "Doe",
"email_address": "[email protected]"
}
},
"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": "<your_public_key>",
"secretKey": "<your_secret_key>"
},
"depositPendingTransaction": {
"id": "<id>",
"status": "any pending_ status"
},
"depositCompletedTransaction": {
"id": "<id>",
"status": "completed",
"stellar_transaction_id": "<valid_completed_deposit_transaction_id>"
},
"withdrawPendingUserTransferStartTransaction": {
"id": "<id>",
"status": "pending_user_transfer_start",
"amount_in": "222.00",
"amount_in_asset": "",
"withdraw_anchor_account": "",
"withdraw_memo": "<id>",
"withdraw_memo_type": "text"
},
"withdrawCompletedTransaction": {
"id": "<id>",
"status": "completed",
"stellar_transaction_id": "<valid_completed_withdraw_transaction_id>"
}
},
"31": {
"sendingAnchorClientSecret": "<secret>",
"sendingClientName": "sendingClient",
"receivingClientName": "receivingClient",
"transactionFields": {
"receiver_account_number": "123",
"receiver_routing_number": "456",
"type": "SWIFT"
}
},
"38": {
"contexts": ["sep31"]
}
}
```
2 changes: 1 addition & 1 deletion @stellar/anchor-tests/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
44 changes: 20 additions & 24 deletions @stellar/anchor-tests/src/tests/sep24/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ const hasProperPendingDepositTransactionSchema: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down Expand Up @@ -273,10 +272,9 @@ const hasProperCompletedDepositTransactionSchema: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down Expand Up @@ -403,10 +401,11 @@ export const hasProperPendingWithdrawTransactionSchema: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down Expand Up @@ -485,10 +484,9 @@ export const hasProperCompletedWithdrawTransactionSchema: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down Expand Up @@ -562,10 +560,9 @@ const returnsDepositTransactionForStellarTxId: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down Expand Up @@ -631,10 +628,9 @@ const returnsWithdrawTransactionForStellarTxId: Test = {
async run(config: Config): Promise<Result> {
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;
}

Expand Down

0 comments on commit 5c7f419

Please sign in to comment.