aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/integrationtests/test-wallettesting.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-11-09 13:32:08 +0100
committerFlorian Dold <florian@dold.me>2023-11-09 14:54:27 +0100
commit7e3d6938bf5184b88ab4d0b75e4dc3d10af7c60a (patch)
tree788fc3b96d0aece0810c0654f9e0162eb9c1fe67 /packages/taler-harness/src/integrationtests/test-wallettesting.ts
parent1024665001060b8a33378ff45f12426a1b152f25 (diff)
downloadwallet-core-7e3d6938bf5184b88ab4d0b75e4dc3d10af7c60a.tar.xz
wallet-core: fix bogus timestamp logic
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-wallettesting.ts')
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallettesting.ts56
1 files changed, 33 insertions, 23 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-wallettesting.ts b/packages/taler-harness/src/integrationtests/test-wallettesting.ts
index 69637b875..6b4444d07 100644
--- a/packages/taler-harness/src/integrationtests/test-wallettesting.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallettesting.ts
@@ -34,7 +34,11 @@ import {
WalletCli,
generateRandomPayto,
} from "../harness/harness.js";
-import { SimpleTestEnvironment } from "../harness/helpers.js";
+import {
+ SimpleTestEnvironment,
+ SimpleTestEnvironmentNg,
+ createWalletDaemonWithClient,
+} from "../harness/helpers.js";
const merchantAuthToken = "secret-token:sandbox";
@@ -45,7 +49,7 @@ const merchantAuthToken = "secret-token:sandbox";
export async function createMyEnvironment(
t: GlobalTestState,
coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")),
-): Promise<SimpleTestEnvironment> {
+): Promise<SimpleTestEnvironmentNg> {
const db = await setupDb(t);
const bank = await BankService.create(t, {
@@ -99,13 +103,19 @@ export async function createMyEnvironment(
console.log("setup done!");
- const wallet = new WalletCli(t);
+ const { walletClient, walletService } = await createWalletDaemonWithClient(
+ t,
+ {
+ name: "w1",
+ },
+ );
return {
commonDb: db,
exchange,
merchant,
- wallet,
+ walletClient,
+ walletService,
bank,
exchangeBankAccount,
};
@@ -115,9 +125,11 @@ export async function createMyEnvironment(
* Run test for basic, bank-integrated withdrawal.
*/
export async function runWallettestingTest(t: GlobalTestState) {
- const { wallet, bank, exchange, merchant } = await createMyEnvironment(t);
+ const { walletClient, bank, exchange, merchant } = await createMyEnvironment(
+ t,
+ );
- await wallet.client.call(WalletApiOperation.RunIntegrationTest, {
+ await walletClient.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "TESTKUDOS:5" as AmountString,
amountToWithdraw: "TESTKUDOS:10" as AmountString,
corebankApiBaseUrl: bank.corebankApiBaseUrl,
@@ -126,7 +138,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
});
- let txns = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ let txns = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txns, undefined, 2));
let txTypes = txns.transactions.map((x) => x.type);
@@ -139,42 +151,42 @@ export async function runWallettestingTest(t: GlobalTestState) {
"payment",
]);
- wallet.deleteDatabase();
+ await walletClient.call(WalletApiOperation.ClearDb, {});
- await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
+ await walletClient.call(WalletApiOperation.WithdrawTestBalance, {
amount: "TESTKUDOS:10" as AmountString,
corebankApiBaseUrl: bank.corebankApiBaseUrl,
exchangeBaseUrl: exchange.baseUrl,
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- await wallet.client.call(WalletApiOperation.TestPay, {
+ await walletClient.call(WalletApiOperation.TestPay, {
amount: "TESTKUDOS:5" as AmountString,
merchantAuthToken: merchantAuthToken,
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
summary: "foo",
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- txns = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+ txns = await walletClient.call(WalletApiOperation.GetTransactions, {});
console.log(JSON.stringify(txns, undefined, 2));
txTypes = txns.transactions.map((x) => x.type);
t.assertDeepEqual(txTypes, ["withdrawal", "payment"]);
- wallet.deleteDatabase();
+ await walletClient.call(WalletApiOperation.ClearDb, {});
- await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
+ await walletClient.call(WalletApiOperation.WithdrawTestBalance, {
amount: "TESTKUDOS:10" as AmountString,
corebankApiBaseUrl: bank.corebankApiBaseUrl,
exchangeBaseUrl: exchange.baseUrl,
});
- await wallet.runUntilDone();
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {});
+ const coinDump = await walletClient.call(WalletApiOperation.DumpCoins, {});
console.log("coin dump:", JSON.stringify(coinDump, undefined, 2));
@@ -194,7 +206,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
console.log("suspending coin");
- await wallet.client.call(WalletApiOperation.SetCoinSuspended, {
+ await walletClient.call(WalletApiOperation.SetCoinSuspended, {
coinPub: susp,
suspended: true,
});
@@ -202,7 +214,7 @@ export async function runWallettestingTest(t: GlobalTestState) {
// This should fail, as we've suspended a coin that we need
// to pay.
await t.assertThrowsAsync(async () => {
- await wallet.client.call(WalletApiOperation.TestPay, {
+ await walletClient.call(WalletApiOperation.TestPay, {
amount: "TESTKUDOS:5" as AmountString,
merchantAuthToken: merchantAuthToken,
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
@@ -212,19 +224,17 @@ export async function runWallettestingTest(t: GlobalTestState) {
console.log("unsuspending coin");
- await wallet.client.call(WalletApiOperation.SetCoinSuspended, {
+ await walletClient.call(WalletApiOperation.SetCoinSuspended, {
coinPub: susp,
suspended: false,
});
- await wallet.client.call(WalletApiOperation.TestPay, {
+ await walletClient.call(WalletApiOperation.TestPay, {
amount: "TESTKUDOS:5" as AmountString,
merchantAuthToken: merchantAuthToken,
merchantBaseUrl: merchant.makeInstanceBaseUrl(),
summary: "foo",
});
-
- await t.shutdown();
}
runWallettestingTest.suites = ["wallet"];