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]) } } }