diff options
author | Florian Dold <florian@dold.me> | 2024-02-07 13:49:05 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-02-07 13:49:05 +0100 |
commit | 56f4b81f9cc1ebf93aaf5b686003530bc9af24e3 (patch) | |
tree | d84963c018bf1b66e6997a015e8b93635165ce5c | |
parent | ff13acded0f68c66577eab96afb7f5242197b540 (diff) | |
download | wallet-core-56f4b81f9cc1ebf93aaf5b686003530bc9af24e3.tar.xz |
remove rewards
Some remains are kept to not break old wallets
m--------- | build-system/taler-build-scripts | 0 | ||||
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts | 38 | ||||
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-tipping.ts | 151 | ||||
-rw-r--r-- | packages/taler-harness/src/integrationtests/testrunner.ts | 23 | ||||
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 13 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 24 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 12 |
7 files changed, 10 insertions, 251 deletions
diff --git a/build-system/taler-build-scripts b/build-system/taler-build-scripts -Subproject 001f5dd081fc8729ff8def90c4a1c3f93eb8689 +Subproject 23538677f6c6be2a62f38dc6137ecdd1c76b7b1 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 bd4318498..8ca00359c 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-merchant.ts @@ -216,44 +216,6 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) { justification: "why not?", next_url: "https://example.com/after-tip", }); - - const { walletClient: walletClientTipping } = - await createWalletDaemonWithClient(t, { - name: "age-tipping", - }); - - const ptr = await walletClientTipping.call( - WalletApiOperation.PrepareReward, - { - talerRewardUri: tip.taler_reward_uri, - }, - ); - - await walletClientTipping.call(WalletApiOperation.AcceptReward, { - walletRewardId: ptr.walletRewardId, - }); - - await walletClientTipping.call( - WalletApiOperation.TestingWaitTransactionsFinal, - {}, - ); - - const order = { - summary: "Buy me!", - amount: "TESTKUDOS:4", - fulfillment_url: "taler://fulfillment-success/thx", - minimum_age: 9, - }; - - await makeTestPaymentV2(t, { - walletClient: walletClientTipping, - merchant, - order, - }); - await walletClientTipping.call( - WalletApiOperation.TestingWaitTransactionsFinal, - {}, - ); } } diff --git a/packages/taler-harness/src/integrationtests/test-tipping.ts b/packages/taler-harness/src/integrationtests/test-tipping.ts deleted file mode 100644 index 543e7a68b..000000000 --- a/packages/taler-harness/src/integrationtests/test-tipping.ts +++ /dev/null @@ -1,151 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/** - * Imports. - */ -import { - TalerCorebankApiClient, - MerchantApiClient, - TransactionMajorState, - WireGatewayApiClient, - AmountString, - TransactionIdStr, -} from "@gnu-taler/taler-util"; -import { - WalletApiOperation, -} from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState, getWireMethodForTest } from "../harness/harness.js"; -import { createSimpleTestkudosEnvironmentV2 } from "../harness/helpers.js"; - -/** - * Run test for basic, bank-integrated withdrawal. - */ -export async function runTippingTest(t: GlobalTestState) { - // Set up test environment - - const { walletClient, bank, exchange, merchant, exchangeBankAccount } = - await createSimpleTestkudosEnvironmentV2(t); - - const bankAccessApiClient = new TalerCorebankApiClient( - bank.corebankApiBaseUrl, - ); - const mbu = await bankAccessApiClient.createRandomBankUser(); - - const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl()); - - const tipReserveResp = await merchantClient.createTippingReserve({ - exchange_url: exchange.baseUrl, - initial_balance: "TESTKUDOS:10" as AmountString, - wire_method: getWireMethodForTest(), - }); - - console.log("tipReserveResp:", tipReserveResp); - - t.assertDeepEqual( - tipReserveResp.accounts[0].payto_uri, - exchangeBankAccount.accountPaytoUri, - ); - - const wireGatewayApiClient = new WireGatewayApiClient( - exchangeBankAccount.wireGatewayApiBaseUrl, - { - auth: { - username: exchangeBankAccount.accountName, - password: exchangeBankAccount.accountPassword, - }, - }, - ); - - await wireGatewayApiClient.adminAddIncoming({ - amount: "TESTKUDOS:10", - debitAccountPayto: mbu.accountPaytoUri, - reservePub: tipReserveResp.reserve_pub, - }); - - await exchange.runWirewatchOnce(); - - await merchant.stop(); - await merchant.start(); - await merchant.pingUntilAvailable(); - - const r = await merchantClient.queryTippingReserves(); - console.log("tipping reserves:", JSON.stringify(r, undefined, 2)); - - t.assertTrue(r.reserves.length === 1); - t.assertDeepEqual( - r.reserves[0].exchange_initial_amount, - r.reserves[0].merchant_initial_amount, - ); - - const tip = await merchantClient.giveTip({ - amount: "TESTKUDOS:5" as AmountString, - justification: "why not?", - next_url: "https://example.com/after-tip", - }); - - console.log("created tip", tip); - - const doTip = async (): Promise<void> => { - const ptr = await walletClient.call(WalletApiOperation.PrepareReward, { - talerRewardUri: tip.taler_reward_uri, - }); - - console.log(ptr); - - t.assertAmountEquals(ptr.rewardAmountRaw, "TESTKUDOS:5"); - t.assertAmountEquals(ptr.rewardAmountEffective, "TESTKUDOS:4.85"); - - await walletClient.call(WalletApiOperation.AcceptReward, { - transactionId: ptr.transactionId, - }); - - await walletClient.call( - WalletApiOperation.TestingWaitTransactionsFinal, - {}, - ); - - const bal = await walletClient.call(WalletApiOperation.GetBalances, {}); - - console.log(bal); - - t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.85"); - - const txns = await walletClient.call( - WalletApiOperation.GetTransactions, - {}, - ); - - console.log("Transactions:", JSON.stringify(txns, undefined, 2)); - - t.assertDeepEqual(txns.transactions[0].type, "reward"); - t.assertDeepEqual( - txns.transactions[0].txState.major, - TransactionMajorState.Done, - ); - t.assertAmountEquals( - txns.transactions[0].amountEffective, - "TESTKUDOS:4.85", - ); - t.assertAmountEquals(txns.transactions[0].amountRaw, "TESTKUDOS:5.0"); - }; - - // Check twice so make sure tip handling is idempotent - await doTip(); - await doTip(); -} - -runTippingTest.suites = ["wallet", "wallet-tipping"]; diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 81047e267..624b230d3 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -28,12 +28,14 @@ import { shouldLingerInTest, } from "../harness/harness.js"; import { getSharedTestDir } from "../harness/helpers.js"; +import { runAgeRestrictionsDepositTest } from "./test-age-restrictions-deposit.js"; import { runAgeRestrictionsMerchantTest } from "./test-age-restrictions-merchant.js"; import { runAgeRestrictionsMixedMerchantTest } from "./test-age-restrictions-mixed-merchant.js"; import { runAgeRestrictionsPeerTest } from "./test-age-restrictions-peer.js"; import { runBankApiTest } from "./test-bank-api.js"; import { runClaimLoopTest } from "./test-claim-loop.js"; import { runClauseSchnorrTest } from "./test-clause-schnorr.js"; +import { runCurrencyScopeTest } from "./test-currency-scope.js"; import { runDenomUnofferedTest } from "./test-denom-unoffered.js"; import { runDepositTest } from "./test-deposit.js"; import { runExchangeDepositTest } from "./test-exchange-deposit.js"; @@ -43,6 +45,7 @@ import { runExchangeTimetravelTest } from "./test-exchange-timetravel.js"; import { runFeeRegressionTest } from "./test-fee-regression.js"; import { runForcedSelectionTest } from "./test-forced-selection.js"; import { runKycTest } from "./test-kyc.js"; +import { runLibeufinBankTest } from "./test-libeufin-bank.js"; import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confusion.js"; import { runMerchantInstancesDeleteTest } from "./test-merchant-instances-delete.js"; import { runMerchantInstancesUrlsTest } from "./test-merchant-instances-urls.js"; @@ -50,9 +53,12 @@ import { runMerchantInstancesTest } from "./test-merchant-instances.js"; import { runMerchantLongpollingTest } from "./test-merchant-longpolling.js"; import { runMerchantRefundApiTest } from "./test-merchant-refund-api.js"; import { runMerchantSpecPublicOrdersTest } from "./test-merchant-spec-public-orders.js"; +import { runMultiExchangeTest } from "./test-multiexchange.js"; +import { runOtpTest } from "./test-otp.js"; import { runPayPaidTest } from "./test-pay-paid.js"; import { runPaymentAbortTest } from "./test-payment-abort.js"; import { runPaymentClaimTest } from "./test-payment-claim.js"; +import { runPaymentDeletedTest } from "./test-payment-deleted.js"; import { runPaymentExpiredTest } from "./test-payment-expired.js"; import { runPaymentFaultTest } from "./test-payment-fault.js"; import { runPaymentForgettableTest } from "./test-payment-forgettable.js"; @@ -76,32 +82,24 @@ import { runSimplePaymentTest } from "./test-simple-payment.js"; import { runStoredBackupsTest } from "./test-stored-backups.js"; import { runTimetravelAutorefreshTest } from "./test-timetravel-autorefresh.js"; import { runTimetravelWithdrawTest } from "./test-timetravel-withdraw.js"; -import { runTippingTest } from "./test-tipping.js"; import { runTermOfServiceFormatTest } from "./test-tos-format.js"; import { runWalletBackupBasicTest } from "./test-wallet-backup-basic.js"; import { runWalletBackupDoublespendTest } from "./test-wallet-backup-doublespend.js"; import { runWalletBalanceTest } from "./test-wallet-balance.js"; import { runWalletCryptoWorkerTest } from "./test-wallet-cryptoworker.js"; import { runWalletDblessTest } from "./test-wallet-dbless.js"; +import { runWalletDd48Test } from "./test-wallet-dd48.js"; +import { runWalletGenDbTest } from "./test-wallet-gendb.js"; import { runWalletNotificationsTest } from "./test-wallet-notifications.js"; +import { runWalletRefreshTest } from "./test-wallet-refresh.js"; import { runWallettestingTest } from "./test-wallettesting.js"; import { runWithdrawalAbortBankTest } from "./test-withdrawal-abort-bank.js"; import { runWithdrawalBankIntegratedTest } from "./test-withdrawal-bank-integrated.js"; +import { runWithdrawalConversionTest } from "./test-withdrawal-conversion.js"; import { runWithdrawalFakebankTest } from "./test-withdrawal-fakebank.js"; import { runWithdrawalFeesTest } from "./test-withdrawal-fees.js"; import { runWithdrawalHugeTest } from "./test-withdrawal-huge.js"; import { runWithdrawalManualTest } from "./test-withdrawal-manual.js"; -import { runWalletGenDbTest } from "./test-wallet-gendb.js"; -import { runLibeufinBankTest } from "./test-libeufin-bank.js"; -import { runCurrencyScopeTest } from "./test-currency-scope.js"; -import { runAgeRestrictionsDepositTest } from "./test-age-restrictions-deposit.js"; -import { runWithdrawalConversionTest } from "./test-withdrawal-conversion.js"; -import { runPaymentDeletedTest } from "./test-payment-deleted.js"; -import { runWithdrawalNotifyBeforeTxTest } from "./test-withdrawal-notify-before-tx.js"; -import { runWalletDd48Test } from "./test-wallet-dd48.js"; -import { runMultiExchangeTest } from "./test-multiexchange.js"; -import { runWalletRefreshTest } from "./test-wallet-refresh.js"; -import { runOtpTest } from "./test-otp.js"; /** * Test runner. @@ -169,7 +167,6 @@ const allTests: TestMainFunction[] = [ runWithdrawalManualTest, runTimetravelAutorefreshTest, runTimetravelWithdrawTest, - runTippingTest, runWalletBackupBasicTest, runWalletBackupDoublespendTest, runWalletNotificationsTest, diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 8603f7445..900649c61 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -665,19 +665,6 @@ walletCli alwaysYes: args.handleUri.autoYes, }); break; - case TalerUriAction.Reward: { - const res = await wallet.client.call( - WalletApiOperation.PrepareReward, - { - talerRewardUri: uri, - }, - ); - console.log("tip status", res); - await wallet.client.call(WalletApiOperation.AcceptReward, { - walletRewardId: res.walletRewardId, - }); - break; - } case TalerUriAction.Refund: await wallet.client.call(WalletApiOperation.StartRefundQueryForUri, { talerRefundUri: uri, diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 38b944475..cdde2ee62 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -206,8 +206,6 @@ export enum WalletApiOperation { DumpCoins = "dumpCoins", SetCoinSuspended = "setCoinSuspended", ForceRefresh = "forceRefresh", - PrepareReward = "prepareReward", - AcceptReward = "acceptReward", ExportBackup = "exportBackup", AddBackupProvider = "addBackupProvider", RemoveBackupProvider = "removeBackupProvider", @@ -611,26 +609,6 @@ export type RemoveGlobalCurrencyAuditorOp = { response: EmptyObject; }; -// group: Rewards - -/** - * Query and store information about a reward. - */ -export type PrepareTipOp = { - op: WalletApiOperation.PrepareReward; - request: PrepareRewardRequest; - response: PrepareRewardResult; -}; - -/** - * Accept a reward. - */ -export type AcceptTipOp = { - op: WalletApiOperation.AcceptReward; - request: AcceptRewardRequest; - response: AcceptTipResponse; -}; - // group: Exchange Management /** @@ -1219,8 +1197,6 @@ export type WalletOperations = { [WalletApiOperation.ForceRefresh]: ForceRefreshOp; [WalletApiOperation.DeleteTransaction]: DeleteTransactionOp; [WalletApiOperation.RetryTransaction]: RetryTransactionOp; - [WalletApiOperation.PrepareReward]: PrepareTipOp; - [WalletApiOperation.AcceptReward]: AcceptTipOp; [WalletApiOperation.StartRefundQueryForUri]: StartRefundQueryForUriOp; [WalletApiOperation.StartRefundQuery]: StartRefundQueryOp; [WalletApiOperation.GetWithdrawalDetailsForAmount]: GetWithdrawalDetailsForAmountOp; diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 28523654b..0b7229cf3 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1171,10 +1171,6 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( const req = codecForForceRefreshRequest().decode(payload); return await forceRefresh(ws, req); } - case WalletApiOperation.PrepareReward: { - const req = codecForPrepareRewardRequest().decode(payload); - return await prepareReward(ws, req.talerRewardUri); - } case WalletApiOperation.StartRefundQueryForUri: { const req = codecForPrepareRefundRequest().decode(payload); return await startRefundQueryForUri(ws, req.talerRefundUri); @@ -1191,14 +1187,6 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( await startQueryRefund(ws, txIdParsed.proposalId); return {}; } - case WalletApiOperation.AcceptReward: { - const req = codecForAcceptTipRequest().decode(payload); - return await acceptTipBackwardCompat( - ws, - req.walletRewardId, - req.transactionId, - ); - } case WalletApiOperation.AddBackupProvider: { const req = codecForAddBackupProviderRequest().decode(payload); return await addBackupProvider(ws, req); |