diff options
Diffstat (limited to 'packages/taler-harness/src')
5 files changed, 73 insertions, 37 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 940e4258a..c9202c60e 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -51,8 +51,8 @@ import { stringToBytes, TalerError, TalerProtocolDuration, - TipCreateConfirmation, - TipCreateRequest, + RewardCreateConfirmation, + RewardCreateRequest, TippingReserveStatus, WalletNotification, } from "@gnu-taler/taler-util"; @@ -1751,8 +1751,8 @@ export namespace MerchantPrivateApi { export async function giveTip( merchantService: MerchantServiceInterface, instance: string, - req: TipCreateRequest, - ): Promise<TipCreateConfirmation> { + req: RewardCreateRequest, + ): Promise<RewardCreateConfirmation> { const reqUrl = new URL( `private/tips`, merchantService.makeInstanceBaseUrl(instance), diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts index c4db7022d..919097deb 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts @@ -191,12 +191,12 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { const walletTipping = new WalletCli(t, "age-tipping"); - const ptr = await walletTipping.client.call(WalletApiOperation.PrepareTip, { - talerTipUri: tip.taler_tip_uri, + const ptr = await walletTipping.client.call(WalletApiOperation.PrepareReward, { + talerRewardUri: tip.taler_reward_uri, }); - await walletTipping.client.call(WalletApiOperation.AcceptTip, { - walletTipId: ptr.walletTipId, + await walletTipping.client.call(WalletApiOperation.AcceptReward, { + walletRewardId: ptr.walletRewardId, }); await walletTipping.runUntilDone(); diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts index eae04cd2e..d15858322 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts @@ -17,13 +17,20 @@ /** * Imports. */ -import { AbsoluteTime, Duration } from "@gnu-taler/taler-util"; +import { + AbsoluteTime, + Duration, + NotificationType, + TransactionMajorState, + TransactionMinorState, +} from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { defaultCoinConfig } from "../harness/denomStructures.js"; import { GlobalTestState, WalletCli } from "../harness/harness.js"; import { - createSimpleTestkudosEnvironment, - withdrawViaBank, + createSimpleTestkudosEnvironmentV2, + createWalletDaemonWithClient, + withdrawViaBankV2, } from "../harness/helpers.js"; /** @@ -32,12 +39,7 @@ import { export async function runAgeRestrictionsPeerTest(t: GlobalTestState) { // Set up test environment - const { - wallet: walletOne, - bank, - exchange, - merchant, - } = await createSimpleTestkudosEnvironment( + const { bank, exchange } = await createSimpleTestkudosEnvironmentV2( t, defaultCoinConfig.map((x) => x("TESTKUDOS")), { @@ -45,20 +47,29 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) { }, ); - const walletTwo = new WalletCli(t, "walletTwo"); - const walletThree = new WalletCli(t, "walletThree"); + const w1 = await createWalletDaemonWithClient(t, { + name: "w1", + persistent: true, + }); + const w2 = await createWalletDaemonWithClient(t, { + name: "w2", + persistent: true, + }); - { - const wallet = walletOne; + const wallet1 = w1.walletClient; + const wallet2 = w2.walletClient; - await withdrawViaBank(t, { - wallet, + { + const withdrawalRes = await withdrawViaBankV2(t, { + walletClient: wallet1, bank, exchange, amount: "TESTKUDOS:20", restrictAge: 13, }); + await withdrawalRes.withdrawalFinishedCond; + const purse_expiration = AbsoluteTime.toProtocolTimestamp( AbsoluteTime.addDuration( AbsoluteTime.now(), @@ -66,7 +77,7 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) { ), ); - const initResp = await wallet.client.call( + const initResp = await wallet1.client.call( WalletApiOperation.InitiatePeerPushDebit, { partialContractTerms: { @@ -77,20 +88,35 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) { }, ); - await wallet.runUntilDone(); + const peerPushReadyCond = wallet1.waitForNotificationCond( + (x) => + x.type === NotificationType.TransactionStateTransition && + x.newTxState.major === TransactionMajorState.Pending && + x.newTxState.minor === TransactionMinorState.Ready && + x.transactionId === initResp.transactionId, + ); + + await peerPushReadyCond; - const checkResp = await walletTwo.client.call( + const checkResp = await wallet2.call( WalletApiOperation.PreparePeerPushCredit, { talerUri: initResp.talerUri, }, ); - await walletTwo.client.call(WalletApiOperation.ConfirmPeerPushCredit, { + await wallet2.call(WalletApiOperation.ConfirmPeerPushCredit, { peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId, }); - await walletTwo.runUntilDone(); + const peerPullCreditDoneCond = wallet2.waitForNotificationCond( + (x) => + x.type === NotificationType.TransactionStateTransition && + x.newTxState.major === TransactionMajorState.Done && + x.transactionId === checkResp.transactionId, + ); + + await peerPullCreditDoneCond; } } diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts index 30287b51b..5b55b1de1 100644 --- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts +++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts @@ -23,6 +23,7 @@ import { j2s, NotificationType, TransactionMajorState, + TransactionMinorState, WalletNotification, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -46,12 +47,14 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) { const w1 = await createWalletDaemonWithClient(t, { name: "w1", + persistent: true, handleNotification(wn) { allW1Notifications.push(wn); }, }); const w2 = await createWalletDaemonWithClient(t, { name: "w2", + persistent: true, handleNotification(wn) { allW2Notifications.push(wn); }, @@ -89,6 +92,15 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) { }, ); + const peerPullCreditReadyCond = wallet1.waitForNotificationCond( + (x) => x.type === NotificationType.TransactionStateTransition && + x.transactionId === resp.transactionId && + x.newTxState.major === TransactionMajorState.Pending && + x.newTxState.minor === TransactionMinorState.Ready, + ); + + await peerPullCreditReadyCond; + const checkResp = await wallet2.client.call( WalletApiOperation.PreparePeerPullDebit, { @@ -98,8 +110,6 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) { console.log(`checkResp: ${j2s(checkResp)}`); - // FIXME: The wallet should emit a more appropriate notification here. - // Yes, it's technically a withdrawal. const peerPullCreditDoneCond = wallet1.waitForNotificationCond( (x) => x.type === NotificationType.TransactionStateTransition && x.transactionId === resp.transactionId && diff --git a/packages/taler-harness/src/integrationtests/test-tipping.ts b/packages/taler-harness/src/integrationtests/test-tipping.ts index ff6fc9ceb..332f702d7 100644 --- a/packages/taler-harness/src/integrationtests/test-tipping.ts +++ b/packages/taler-harness/src/integrationtests/test-tipping.ts @@ -99,17 +99,17 @@ export async function runTippingTest(t: GlobalTestState) { console.log("created tip", tip); const doTip = async (): Promise<void> => { - const ptr = await wallet.client.call(WalletApiOperation.PrepareTip, { - talerTipUri: tip.taler_tip_uri, + const ptr = await wallet.client.call(WalletApiOperation.PrepareReward, { + talerRewardUri: tip.taler_reward_uri, }); console.log(ptr); - t.assertAmountEquals(ptr.tipAmountRaw, "TESTKUDOS:5"); - t.assertAmountEquals(ptr.tipAmountEffective, "TESTKUDOS:4.85"); + t.assertAmountEquals(ptr.rewardAmountRaw, "TESTKUDOS:5"); + t.assertAmountEquals(ptr.rewardAmountEffective, "TESTKUDOS:4.85"); - await wallet.client.call(WalletApiOperation.AcceptTip, { - walletTipId: ptr.walletTipId, + await wallet.client.call(WalletApiOperation.AcceptReward, { + walletRewardId: ptr.walletRewardId, }); await wallet.runUntilDone(); @@ -127,7 +127,7 @@ export async function runTippingTest(t: GlobalTestState) { console.log("Transactions:", JSON.stringify(txns, undefined, 2)); - t.assertDeepEqual(txns.transactions[0].type, "tip"); + t.assertDeepEqual(txns.transactions[0].type, "reward"); t.assertDeepEqual(txns.transactions[0].txState.major, TransactionMajorState.Done); t.assertAmountEquals( txns.transactions[0].amountEffective, |