aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/db.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/testing.ts60
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts91
3 files changed, 68 insertions, 85 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index d59085dcc..3e8452bcd 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -189,7 +189,7 @@ export function timestampPreciseToDb(
} else {
let tUs = stamp.t_s * 1000000;
if (stamp.off_us) {
- tUs == stamp.off_us;
+ tUs += stamp.off_us;
}
return tUs as DbPreciseTimestamp;
}
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts
index 3fff9ccaa..62766556c 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -15,66 +15,66 @@
*/
/**
+ * @file
+ * Implementation of wallet-core operations that are used for testing,
+ * but typically not in the production wallet.
+ */
+
+/**
* Imports.
*/
import {
AbsoluteTime,
- base64FromArrayBuffer,
+ Amounts,
+ AmountString,
+ CheckPaymentResponse,
+ codecForAny,
+ codecForCheckPaymentResponse,
ConfirmPayResultType,
Duration,
+ IntegrationTestArgs,
IntegrationTestV2Args,
j2s,
Logger,
NotificationType,
- RegisterAccountRequest,
- stringToBytes,
+ PreparePayResultType,
TalerCorebankApiClient,
+ TestPayArgs,
TestPayResult,
TransactionMajorState,
TransactionMinorState,
TransactionState,
TransactionType,
+ URL,
WithdrawTestBalanceRequest,
} from "@gnu-taler/taler-util";
import {
HttpRequestLibrary,
readSuccessResponseJsonOrThrow,
- checkSuccessResponseOrThrow,
} from "@gnu-taler/taler-util/http";
-import {
- AmountString,
- codecForAny,
- CheckPaymentResponse,
- codecForCheckPaymentResponse,
- IntegrationTestArgs,
- Amounts,
- TestPayArgs,
- URL,
- PreparePayResultType,
-} from "@gnu-taler/taler-util";
+import { OpenedPromise, openPromise } from "../index.js";
import { InternalWalletState } from "../internal-wallet-state.js";
+import { checkLogicInvariant } from "../util/invariants.js";
+import { getBalances } from "./balance.js";
+import { updateExchangeFromUrl } from "./exchanges.js";
import {
confirmPay,
preparePayForUri,
startRefundQueryForUri,
} from "./pay-merchant.js";
-import { getBalances } from "./balance.js";
-import { checkLogicInvariant } from "../util/invariants.js";
-import { acceptWithdrawalFromUri } from "./withdraw.js";
-import { updateExchangeFromUrl } from "./exchanges.js";
import { initiatePeerPullPayment } from "./pay-peer-pull-credit.js";
import {
- preparePeerPullDebit,
confirmPeerPullDebit,
+ preparePeerPullDebit,
} from "./pay-peer-pull-debit.js";
import {
- preparePeerPushCredit,
confirmPeerPushCredit,
+ preparePeerPushCredit,
} from "./pay-peer-push-credit.js";
import { initiatePeerPushDebit } from "./pay-peer-push-debit.js";
-import { OpenedPromise, openPromise } from "../index.js";
-import { getTransactionById, getTransactions } from "./transactions.js";
import { getPendingOperations } from "./pending.js";
+import { getTransactionById, getTransactions } from "./transactions.js";
+import { acceptWithdrawalFromUri } from "./withdraw.js";
const logger = new Logger("operations/testing.ts");
@@ -83,20 +83,6 @@ interface MerchantBackendInfo {
authToken?: string;
}
-/**
- * Generate a random alphanumeric ID. Does *not* use cryptographically
- * secure randomness.
- */
-function makeId(length: number): string {
- let result = "";
- const characters =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- for (let i = 0; i < length; i++) {
- result += characters.charAt(Math.floor(Math.random() * characters.length));
- }
- return result;
-}
-
export async function withdrawTestBalance(
ws: InternalWalletState,
req: WithdrawTestBalanceRequest,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index bebb3d60b..33ee2b424 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -31,8 +31,6 @@ import {
stringifyPayPullUri,
stringifyPayPushUri,
TalerErrorCode,
- TalerPreciseTimestamp,
- TalerProtocolTimestamp,
Transaction,
TransactionByIdRequest,
TransactionIdStr,
@@ -50,12 +48,12 @@ import {
DepositGroupRecord,
ExchangeDetailsRecord,
OperationRetryRecord,
- PeerPullPaymentIncomingRecord,
- PeerPullDebitRecordStatus,
PeerPullCreditRecord,
- PeerPushPaymentIncomingRecord,
+ PeerPullDebitRecordStatus,
+ PeerPullPaymentIncomingRecord,
PeerPushCreditStatus,
PeerPushDebitRecord,
+ PeerPushPaymentIncomingRecord,
PurchaseRecord,
PurchaseStatus,
RefreshGroupRecord,
@@ -68,7 +66,6 @@ import {
} from "../db.js";
import {
GetReadOnlyAccess,
- timestampOptionalPreciseFromDb,
timestampPreciseFromDb,
timestampProtocolFromDb,
WalletStoresV1,
@@ -85,81 +82,56 @@ import {
} from "./common.js";
import {
abortDepositGroup,
- failDepositTransaction,
+ computeDepositTransactionActions,
computeDepositTransactionStatus,
deleteDepositGroup,
+ failDepositTransaction,
resumeDepositGroup,
suspendDepositGroup,
- computeDepositTransactionActions,
} from "./deposits.js";
import { getExchangeDetails } from "./exchanges.js";
import {
abortPayMerchant,
- failPaymentTransaction,
+ computePayMerchantTransactionActions,
computePayMerchantTransactionState,
computeRefundTransactionState,
expectProposalDownload,
extractContractData,
+ failPaymentTransaction,
resumePayMerchant,
suspendPayMerchant,
- computePayMerchantTransactionActions,
} from "./pay-merchant.js";
import {
- abortRefreshGroup,
- failRefreshGroup,
- computeRefreshTransactionState,
- resumeRefreshGroup,
- suspendRefreshGroup,
- computeRefreshTransactionActions,
-} from "./refresh.js";
-import {
- abortTipTransaction,
- failTipTransaction,
- computeRewardTransactionStatus,
- resumeTipTransaction,
- suspendRewardTransaction,
- computeTipTransactionActions,
-} from "./reward.js";
-import {
- abortWithdrawalTransaction,
- augmentPaytoUrisForWithdrawal,
- failWithdrawalTransaction,
- computeWithdrawalTransactionStatus,
- resumeWithdrawalTransaction,
- suspendWithdrawalTransaction,
- computeWithdrawalTransactionActions,
-} from "./withdraw.js";
-import {
- computePeerPullCreditTransactionState,
+ abortPeerPullCreditTransaction,
computePeerPullCreditTransactionActions,
- suspendPeerPullCreditTransaction,
+ computePeerPullCreditTransactionState,
failPeerPullCreditTransaction,
resumePeerPullCreditTransaction,
- abortPeerPullCreditTransaction,
+ suspendPeerPullCreditTransaction,
} from "./pay-peer-pull-credit.js";
import {
- computePeerPullDebitTransactionState,
+ abortPeerPullDebitTransaction,
computePeerPullDebitTransactionActions,
- suspendPeerPullDebitTransaction,
+ computePeerPullDebitTransactionState,
failPeerPullDebitTransaction,
resumePeerPullDebitTransaction,
- abortPeerPullDebitTransaction,
+ suspendPeerPullDebitTransaction,
} from "./pay-peer-pull-debit.js";
import {
- computePeerPushCreditTransactionState,
+ abortPeerPushCreditTransaction,
computePeerPushCreditTransactionActions,
- suspendPeerPushCreditTransaction,
+ computePeerPushCreditTransactionState,
failPeerPushCreditTransaction,
resumePeerPushCreditTransaction,
- abortPeerPushCreditTransaction,
+ suspendPeerPushCreditTransaction,
} from "./pay-peer-push-credit.js";
import {
- computePeerPushDebitTransactionState,
+ abortPeerPushDebitTransaction,
computePeerPushDebitTransactionActions,
- suspendPeerPushDebitTransaction,
+ computePeerPushDebitTransactionState,
failPeerPushDebitTransaction,
resumePeerPushDebitTransaction,
- abortPeerPushDebitTransaction,
+ suspendPeerPushDebitTransaction,
} from "./pay-peer-push-debit.js";
import {
iterRecordsForDeposit,
@@ -173,6 +145,31 @@ import {
iterRecordsForReward,
iterRecordsForWithdrawal,
} from "./pending.js";
+import {
+ abortRefreshGroup,
+ computeRefreshTransactionActions,
+ computeRefreshTransactionState,
+ failRefreshGroup,
+ resumeRefreshGroup,
+ suspendRefreshGroup,
+} from "./refresh.js";
+import {
+ abortTipTransaction,
+ computeRewardTransactionStatus,
+ computeTipTransactionActions,
+ failTipTransaction,
+ resumeTipTransaction,
+ suspendRewardTransaction,
+} from "./reward.js";
+import {
+ abortWithdrawalTransaction,
+ augmentPaytoUrisForWithdrawal,
+ computeWithdrawalTransactionActions,
+ computeWithdrawalTransactionStatus,
+ failWithdrawalTransaction,
+ resumeWithdrawalTransaction,
+ suspendWithdrawalTransaction,
+} from "./withdraw.js";
const logger = new Logger("taler-wallet-core:transactions.ts");