diff options
| author | Özgür Kesim <oec-taler@kesim.org> | 2023-09-09 07:34:11 +0200 |
|---|---|---|
| committer | Özgür Kesim <oec-taler@kesim.org> | 2023-09-09 07:34:11 +0200 |
| commit | 5495551071a3fdc36c38deb4c1cf6f4aa5b98bd4 (patch) | |
| tree | adf7730b190618a0499e50a2d43cf1b850cddd16 /packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts | |
| parent | 94cfcc875065f988815c31aaf8ebf36f75ac5983 (diff) | |
| parent | 6c3cfa9be7a332c2cc8490f25ebd6c73c8244842 (diff) | |
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts')
| -rw-r--r-- | packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts index e3e18d5a4..c761c4fb0 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-backup-doublespend.ts @@ -17,18 +17,14 @@ /** * Imports. */ -import { PreparePayResultType } from "@gnu-taler/taler-util"; +import { MerchantApiClient, PreparePayResultType } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { - GlobalTestState, - MerchantPrivateApi, - WalletCli, -} from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, + createWalletDaemonWithClient, makeTestPaymentV2, - withdrawViaBank, - withdrawViaBankV2 + withdrawViaBankV2, } from "../harness/helpers.js"; import { SyncService } from "../harness/sync.js"; @@ -38,6 +34,8 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { const { commonDb, merchant, walletClient, bank, exchange } = await createSimpleTestkudosEnvironmentV2(t); + const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl()); + const sync = await SyncService.create(t, { currency: "TESTKUDOS", annualFee: "TESTKUDOS:0.5", @@ -58,7 +56,12 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { name: sync.baseUrl, }); - await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:10" }); + await withdrawViaBankV2(t, { + walletClient, + bank, + exchange, + amount: "TESTKUDOS:10", + }); await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); @@ -71,13 +74,16 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { {}, ); - const wallet2 = new WalletCli(t, "wallet2"); + const { walletClient: walletClientTwo } = await createWalletDaemonWithClient( + t, + { name: "default" }, + ); - await wallet2.client.call(WalletApiOperation.ImportBackupRecovery, { + await walletClientTwo.call(WalletApiOperation.ImportBackupRecovery, { recovery: backupRecovery, }); - await wallet2.client.call(WalletApiOperation.RunBackupCycle, {}); + await walletClientTwo.call(WalletApiOperation.RunBackupCycle, {}); console.log( "wallet1 balance before spend:", @@ -103,7 +109,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { { console.log( "wallet2 balance:", - await wallet2.client.call(WalletApiOperation.GetBalances, {}), + await walletClientTwo.call(WalletApiOperation.GetBalances, {}), ); } @@ -112,7 +118,7 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { { const instance = "default"; - const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, { + const orderResp = await merchantClient.createOrder({ order: { amount: "TESTKUDOS:8", summary: "bla", @@ -120,12 +126,9 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { }, }); - let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus( - merchant, - { - orderId: orderResp.order_id, - }, - ); + let orderStatus = await merchantClient.queryPrivateOrderStatus({ + orderId: orderResp.order_id, + }); t.assertTrue(orderStatus.order_status === "unpaid"); @@ -134,11 +137,11 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { { console.log( "wallet2 balance before preparePay:", - await wallet2.client.call(WalletApiOperation.GetBalances, {}), + await walletClientTwo.call(WalletApiOperation.GetBalances, {}), ); } - const preparePayResult = await wallet2.client.call( + const preparePayResult = await walletClientTwo.call( WalletApiOperation.PreparePayForUri, { talerPayUri: orderStatus.taler_pay_uri, @@ -150,25 +153,28 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) { PreparePayResultType.PaymentPossible, ); - const res = await wallet2.client.call(WalletApiOperation.ConfirmPay, { - proposalId: preparePayResult.proposalId, + const res = await walletClientTwo.call(WalletApiOperation.ConfirmPay, { + transactionId: preparePayResult.transactionId, }); console.log(res); // FIXME: wait for a notification that indicates insufficient funds! - await withdrawViaBank(t, { - wallet: wallet2, + await withdrawViaBankV2(t, { + walletClient: walletClientTwo, bank, exchange, amount: "TESTKUDOS:50", }); - const bal = await wallet2.client.call(WalletApiOperation.GetBalances, {}); + const bal = await walletClientTwo.call(WalletApiOperation.GetBalances, {}); console.log("bal", bal); - await wallet2.runUntilDone(); + await walletClientTwo.call( + WalletApiOperation.TestingWaitTransactionsFinal, + {}, + ); } } |
