summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/integrationtests
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-03-10 17:11:59 +0100
committerFlorian Dold <florian@dold.me>2021-03-10 17:11:59 +0100
commit1392dc47c6489fca1b3a4c036852873495190c36 (patch)
treeb8b76bff34b7425de602651fec3d86463e4c7599 /packages/taler-wallet-cli/src/integrationtests
parentac89c3d277134e49e44d8b0afd4930fd4df934aa (diff)
downloadwallet-core-1392dc47c6489fca1b3a4c036852873495190c36.tar.gz
wallet-core-1392dc47c6489fca1b3a4c036852873495190c36.tar.bz2
wallet-core-1392dc47c6489fca1b3a4c036852873495190c36.zip
finish first complete end-to-end backup/sync test
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/harness.ts18
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/sync.ts3
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts60
3 files changed, 76 insertions, 5 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index 835eb7a08..31f9131a3 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -82,6 +82,7 @@ import {
CreateDepositGroupResponse,
TrackDepositGroupRequest,
TrackDepositGroupResponse,
+ RecoveryLoadRequest,
} from "@gnu-taler/taler-wallet-core";
import { URL } from "url";
import axios, { AxiosError } from "axios";
@@ -102,6 +103,7 @@ import { CoinConfig } from "./denomStructures";
import {
AddBackupProviderRequest,
BackupInfo,
+ BackupRecovery,
} from "@gnu-taler/taler-wallet-core/src/operations/backup";
const exec = util.promisify(require("child_process").exec);
@@ -1887,6 +1889,22 @@ export class WalletCli {
throw new OperationFailedError(resp.error);
}
+ async exportBackupRecovery(): Promise<BackupRecovery> {
+ const resp = await this.apiRequest("exportBackupRecovery", {});
+ if (resp.type === "response") {
+ return resp.result as BackupRecovery;
+ }
+ throw new OperationFailedError(resp.error);
+ }
+
+ async importBackupRecovery(req: RecoveryLoadRequest): Promise<void> {
+ const resp = await this.apiRequest("importBackupRecovery", req);
+ if (resp.type === "response") {
+ return;
+ }
+ throw new OperationFailedError(resp.error);
+ }
+
async runBackupCycle(): Promise<void> {
const resp = await this.apiRequest("runBackupCycle", {});
if (resp.type === "response") {
diff --git a/packages/taler-wallet-cli/src/integrationtests/sync.ts b/packages/taler-wallet-cli/src/integrationtests/sync.ts
index 7aa4b2893..83024ec79 100644
--- a/packages/taler-wallet-cli/src/integrationtests/sync.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/sync.ts
@@ -19,7 +19,6 @@
*/
import axios from "axios";
import { Configuration, URL } from "@gnu-taler/taler-wallet-core";
-import { getRandomIban, getRandomString } from "./helpers";
import * as fs from "fs";
import * as util from "util";
import {
@@ -87,6 +86,8 @@ export class SyncService {
config.setString("sync", "port", `${sc.httpPort}`);
config.setString("sync", "db", "postgres");
config.setString("syncdb-postgres", "config", sc.database);
+ config.setString("sync", "payment_backend_url", sc.paymentBackendUrl);
+ config.setString("sync", "upload_limit_mb", `${sc.uploadLimitMb}`);
config.write(cfgFilename);
return new SyncService(gc, sc, cfgFilename);
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
index 9804f7ab2..2ed16fe19 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
@@ -17,9 +17,12 @@
/**
* Imports.
*/
-import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
-import { createSimpleTestkudosEnvironment } from "./helpers";
-import { codecForBalancesResponse } from "@gnu-taler/taler-wallet-core";
+import { GlobalTestState, BankApi, BankAccessApi, WalletCli } from "./harness";
+import {
+ createSimpleTestkudosEnvironment,
+ makeTestPayment,
+ withdrawViaBank,
+} from "./helpers";
import { SyncService } from "./sync";
/**
@@ -28,7 +31,13 @@ import { SyncService } from "./sync";
export async function runWalletBackupBasicTest(t: GlobalTestState) {
// Set up test environment
- const { commonDb, merchant, wallet, bank, exchange } = await createSimpleTestkudosEnvironment(t);
+ const {
+ commonDb,
+ merchant,
+ wallet,
+ bank,
+ exchange,
+ } = await createSimpleTestkudosEnvironment(t);
const sync = await SyncService.create(t, {
currency: "TESTKUDOS",
@@ -69,5 +78,48 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
{
const bi = await wallet.getBackupInfo();
console.log(bi);
+ t.assertDeepEqual(
+ bi.providers[0].paymentStatus.type,
+ "insufficient-balance",
+ );
+ }
+
+ await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
+
+ await wallet.runBackupCycle();
+
+ {
+ const bi = await wallet.getBackupInfo();
+ console.log(bi);
+ }
+
+ await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:5" });
+
+ await wallet.runBackupCycle();
+
+ {
+ const bi = await wallet.getBackupInfo();
+ console.log(bi);
+ }
+
+ const backupRecovery = await wallet.exportBackupRecovery();
+
+ const wallet2 = new WalletCli(t, "wallet2");
+
+ // Check that the second wallet is a fresh wallet.
+ {
+ const bal = await wallet2.getBalances();
+ t.assertTrue(bal.balances.length === 0);
+ }
+
+ await wallet2.importBackupRecovery({ recovery: backupRecovery });
+
+ await wallet2.runBackupCycle();
+
+ // Check that now the old balance is available!
+ {
+ const bal = await wallet2.getBalances();
+ t.assertTrue(bal.balances.length === 1);
+ console.log(bal);
}
}