wallet-core,harness: remove separate fakebank withdrawal API

This commit is contained in:
Florian Dold 2023-09-21 18:02:36 +02:00
parent 58debefbe0
commit a99156ed22
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
7 changed files with 12 additions and 89 deletions

View File

@ -96,10 +96,10 @@ export async function runBench1(configJson: any): Promise<void> {
logger.trace(`Starting withdrawal amount=${withdrawAmount}`); logger.trace(`Starting withdrawal amount=${withdrawAmount}`);
let start = Date.now(); let start = Date.now();
await wallet.client.call(WalletApiOperation.WithdrawFakebank, { await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
amount: b1conf.currency + ":" + withdrawAmount, amount: b1conf.currency + ":" + withdrawAmount,
bank: b1conf.bank, bankAccessApiBaseUrl: b1conf.bank,
exchange: b1conf.exchange, exchangeBaseUrl: b1conf.exchange,
}); });
await wallet.runTaskLoop({ await wallet.runTaskLoop({

View File

@ -107,10 +107,10 @@ export async function runBench3(configJson: any): Promise<void> {
logger.trace(`Starting withdrawal amount=${withdrawAmount}`); logger.trace(`Starting withdrawal amount=${withdrawAmount}`);
let start = Date.now(); let start = Date.now();
await wallet.client.call(WalletApiOperation.WithdrawFakebank, { await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
amount: b3conf.currency + ":" + withdrawAmount, amount: b3conf.currency + ":" + withdrawAmount,
bank: b3conf.bank, bankAccessApiBaseUrl: b3conf.bank,
exchange: b3conf.exchange, exchangeBaseUrl: b3conf.exchange,
}); });
await wallet.runTaskLoop({ await wallet.runTaskLoop({

View File

@ -79,10 +79,10 @@ export async function runWithdrawalFakebankTest(t: GlobalTestState) {
exchangeBaseUrl: exchange.baseUrl, exchangeBaseUrl: exchange.baseUrl,
}); });
await wallet.client.call(WalletApiOperation.WithdrawFakebank, { await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
exchange: exchange.baseUrl, bankAccessApiBaseUrl: bank.bankAccessApiBaseUrl,
exchangeBaseUrl: exchange.baseUrl,
amount: "TESTKUDOS:10", amount: "TESTKUDOS:10",
bank: bank.baseUrl,
}); });
await exchange.runWirewatchOnce(); await exchange.runWirewatchOnce();

View File

@ -99,10 +99,10 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) {
}); });
// Results in about 1K coins withdrawn // Results in about 1K coins withdrawn
await wallet.client.call(WalletApiOperation.WithdrawFakebank, { await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
exchange: exchange.baseUrl, exchangeBaseUrl: exchange.baseUrl,
amount: "TESTKUDOS:10000", amount: "TESTKUDOS:10000",
bank: bank.baseUrl, bankAccessApiBaseUrl: bank.baseUrl,
}); });
await withdrawalFinishedCond; await withdrawalFinishedCond;

View File

@ -1290,29 +1290,6 @@ advancedCli
wallet.stop(); wallet.stop();
}); });
advancedCli
.subcommand("withdrawFakebank", "withdraw-fakebank", {
help: "Withdraw via a fakebank.",
})
.requiredOption("exchange", ["--exchange"], clk.STRING, {
help: "Base URL of the exchange to use",
})
.requiredOption("amount", ["--amount"], clk.STRING, {
help: "Amount to withdraw (before fees).",
})
.requiredOption("bank", ["--bank"], clk.STRING, {
help: "Base URL of the Taler fakebank service.",
})
.action(async (args) => {
await withWallet(args, async (wallet) => {
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
amount: args.withdrawFakebank.amount,
bank: args.withdrawFakebank.bank,
exchange: args.withdrawFakebank.exchange,
});
});
});
advancedCli advancedCli
.subcommand("genSegwit", "gen-segwit") .subcommand("genSegwit", "gen-segwit")
.requiredArgument("paytoUri", clk.STRING) .requiredArgument("paytoUri", clk.STRING)

View File

@ -118,7 +118,6 @@ import {
WalletContractData, WalletContractData,
WalletCoreVersion, WalletCoreVersion,
WalletCurrencyInfo, WalletCurrencyInfo,
WithdrawFakebankRequest,
WithdrawTestBalanceRequest, WithdrawTestBalanceRequest,
WithdrawUriInfoResponse, WithdrawUriInfoResponse,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
@ -199,7 +198,6 @@ export enum WalletApiOperation {
GenerateDepositGroupTxId = "generateDepositGroupTxId", GenerateDepositGroupTxId = "generateDepositGroupTxId",
CreateDepositGroup = "createDepositGroup", CreateDepositGroup = "createDepositGroup",
SetWalletDeviceId = "setWalletDeviceId", SetWalletDeviceId = "setWalletDeviceId",
WithdrawFakebank = "withdrawFakebank",
ImportDb = "importDb", ImportDb = "importDb",
ExportDb = "exportDb", ExportDb = "exportDb",
PreparePeerPushCredit = "preparePeerPushCredit", PreparePeerPushCredit = "preparePeerPushCredit",
@ -934,17 +932,6 @@ export type TestPayOp = {
response: TestPayResult; response: TestPayResult;
}; };
/**
* Make a withdrawal from a fakebank, i.e.
* a bank where test users can be registered freely
* and testing APIs are available.
*/
export type WithdrawFakebankOp = {
op: WalletApiOperation.WithdrawFakebank;
request: WithdrawFakebankRequest;
response: EmptyObject;
};
/** /**
* Get wallet-internal pending tasks. * Get wallet-internal pending tasks.
*/ */
@ -1040,7 +1027,6 @@ export type ForceRefreshOp = {
export type WalletOperations = { export type WalletOperations = {
[WalletApiOperation.InitWallet]: InitWalletOp; [WalletApiOperation.InitWallet]: InitWalletOp;
[WalletApiOperation.GetVersion]: GetVersionOp; [WalletApiOperation.GetVersion]: GetVersionOp;
[WalletApiOperation.WithdrawFakebank]: WithdrawFakebankOp;
[WalletApiOperation.PreparePayForUri]: PreparePayForUriOp; [WalletApiOperation.PreparePayForUri]: PreparePayForUriOp;
[WalletApiOperation.SharePayment]: SharePaymentOp; [WalletApiOperation.SharePayment]: SharePaymentOp;
[WalletApiOperation.PreparePayForTemplate]: PreparePayForTemplateOp; [WalletApiOperation.PreparePayForTemplate]: PreparePayForTemplateOp;

View File

@ -1492,46 +1492,6 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
trustedExchanges: [], trustedExchanges: [],
}; };
} }
case WalletApiOperation.WithdrawFakebank: {
const req = codecForWithdrawFakebankRequest().decode(payload);
const amount = Amounts.parseOrThrow(req.amount);
const details = await getExchangeWithdrawalInfo(
ws,
req.exchange,
amount,
undefined,
);
const wres = await createManualWithdrawal(ws, {
amount: amount,
exchangeBaseUrl: req.exchange,
});
const paytoUri = details.exchangePaytoUris[0];
const pt = parsePaytoUri(paytoUri);
if (!pt) {
throw Error("failed to parse payto URI");
}
const components = pt.targetPath.split("/");
const creditorAcct = components[components.length - 1];
logger.info(`making testbank transfer to '${creditorAcct}'`);
const fbReq = await ws.http.fetch(
new URL(
`accounts/${creditorAcct}/taler-wire-gateway/admin/add-incoming`,
req.bank,
).href,
{
method: "POST",
body: {
amount: Amounts.stringify(amount),
reserve_pub: wres.reservePub,
debit_account:
"payto://x-taler-bank/localhost/testdebtor?receiver-name=Foo",
},
},
);
const fbResp = await readSuccessResponseJsonOrThrow(fbReq, codecForAny());
logger.info(`started fakebank withdrawal: ${j2s(fbResp)}`);
return {};
}
case WalletApiOperation.TestCrypto: { case WalletApiOperation.TestCrypto: {
return await ws.cryptoApi.hashString({ str: "hello world" }); return await ws.cryptoApi.hashString({ str: "hello world" });
} }