From 454b3dd600580a544c236bc0b15cfc4bd909bfd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 16:59:20 +0000 Subject: [PATCH 1/2] Initial plan From a619f3cf779481a0c30a218c476b842710c1f12a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 17:20:56 +0000 Subject: [PATCH 2/2] Fix flaky IAP flow test: remove spurious async and mock delays Agent-Logs-Url: https://github.com/damus-io/api/sessions/9ac7edf6-1445-487b-8ab5-4e8a3fac7d03 Co-authored-by: danieldaquino <24692108+danieldaquino@users.noreply.github.com> --- src/iap_refresh_management.js | 2 +- test/controllers/mock_iap_controller.js | 30 +++++++++---------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/iap_refresh_management.js b/src/iap_refresh_management.js index 042185f..ec8f0c9 100644 --- a/src/iap_refresh_management.js +++ b/src/iap_refresh_management.js @@ -43,7 +43,7 @@ async function update_iap_history_with_apple_if_needed_and_return_updated_user(a } } -async function should_iap_transaction_history_be_refreshed(account) { +function should_iap_transaction_history_be_refreshed(account) { const account_active = (account.expiry && current_time() < account.expiry) ? true : false; const last_transaction = account.transactions[account.transactions.length - 1]; if (account_active || last_transaction == undefined || last_transaction.type != "iap") { diff --git a/test/controllers/mock_iap_controller.js b/test/controllers/mock_iap_controller.js index a9c6b5e..01bf0b2 100644 --- a/test/controllers/mock_iap_controller.js +++ b/test/controllers/mock_iap_controller.js @@ -112,17 +112,12 @@ class MockIAPController { * @returns {Promise} - A promise that resolves with the transaction history */ getTransactionHistory(transactionId, revision, transactionHistoryRequest) { - // TODO: Make this function more realistic - return new Promise((resolve, reject) => { - setTimeout(() => { - if (!this.mock_controller.mock_transaction_data[transactionId]) { - reject(new APIException(400, 4000006)) - } - resolve({ - signedTransactions: this.mock_controller.mock_transaction_data[transactionId], - hasMore: false - }) - }, 500) + if (!this.mock_controller.mock_transaction_data[transactionId]) { + return Promise.reject(new APIException(400, 4000006)) + } + return Promise.resolve({ + signedTransactions: this.mock_controller.mock_transaction_data[transactionId], + hasMore: false }) } } @@ -149,15 +144,10 @@ class MockIAPController { * @returns {Promise} - A promise that resolves with the decoded payload */ verifyAndDecodeTransaction(signedTransactionInfo) { - // TODO: Make this function more realistic - return new Promise((resolve, reject) => { - setTimeout(() => { - if (!MOCK_TRANSACTION_HISTORY_DECODED_DATA[signedTransactionInfo]) { - reject() - } - resolve(MOCK_TRANSACTION_HISTORY_DECODED_DATA[signedTransactionInfo]) - }, 500) - }) + if (!MOCK_TRANSACTION_HISTORY_DECODED_DATA[signedTransactionInfo]) { + return Promise.reject(new Error('Unknown signed transaction')) + } + return Promise.resolve(MOCK_TRANSACTION_HISTORY_DECODED_DATA[signedTransactionInfo]) } } }