wallet-core,harness: remove separate fakebank withdrawal API
This commit is contained in:
parent
58debefbe0
commit
a99156ed22
@ -96,10 +96,10 @@ export async function runBench1(configJson: any): Promise<void> {
|
||||
logger.trace(`Starting withdrawal amount=${withdrawAmount}`);
|
||||
let start = Date.now();
|
||||
|
||||
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
|
||||
await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
|
||||
amount: b1conf.currency + ":" + withdrawAmount,
|
||||
bank: b1conf.bank,
|
||||
exchange: b1conf.exchange,
|
||||
bankAccessApiBaseUrl: b1conf.bank,
|
||||
exchangeBaseUrl: b1conf.exchange,
|
||||
});
|
||||
|
||||
await wallet.runTaskLoop({
|
||||
|
@ -107,10 +107,10 @@ export async function runBench3(configJson: any): Promise<void> {
|
||||
logger.trace(`Starting withdrawal amount=${withdrawAmount}`);
|
||||
let start = Date.now();
|
||||
|
||||
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
|
||||
await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
|
||||
amount: b3conf.currency + ":" + withdrawAmount,
|
||||
bank: b3conf.bank,
|
||||
exchange: b3conf.exchange,
|
||||
bankAccessApiBaseUrl: b3conf.bank,
|
||||
exchangeBaseUrl: b3conf.exchange,
|
||||
});
|
||||
|
||||
await wallet.runTaskLoop({
|
||||
|
@ -79,10 +79,10 @@ export async function runWithdrawalFakebankTest(t: GlobalTestState) {
|
||||
exchangeBaseUrl: exchange.baseUrl,
|
||||
});
|
||||
|
||||
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
|
||||
exchange: exchange.baseUrl,
|
||||
await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
|
||||
bankAccessApiBaseUrl: bank.bankAccessApiBaseUrl,
|
||||
exchangeBaseUrl: exchange.baseUrl,
|
||||
amount: "TESTKUDOS:10",
|
||||
bank: bank.baseUrl,
|
||||
});
|
||||
|
||||
await exchange.runWirewatchOnce();
|
||||
|
@ -99,10 +99,10 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) {
|
||||
});
|
||||
|
||||
// Results in about 1K coins withdrawn
|
||||
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
|
||||
exchange: exchange.baseUrl,
|
||||
await wallet.client.call(WalletApiOperation.WithdrawTestBalance, {
|
||||
exchangeBaseUrl: exchange.baseUrl,
|
||||
amount: "TESTKUDOS:10000",
|
||||
bank: bank.baseUrl,
|
||||
bankAccessApiBaseUrl: bank.baseUrl,
|
||||
});
|
||||
|
||||
await withdrawalFinishedCond;
|
||||
|
@ -1290,29 +1290,6 @@ advancedCli
|
||||
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
|
||||
.subcommand("genSegwit", "gen-segwit")
|
||||
.requiredArgument("paytoUri", clk.STRING)
|
||||
|
@ -118,7 +118,6 @@ import {
|
||||
WalletContractData,
|
||||
WalletCoreVersion,
|
||||
WalletCurrencyInfo,
|
||||
WithdrawFakebankRequest,
|
||||
WithdrawTestBalanceRequest,
|
||||
WithdrawUriInfoResponse,
|
||||
} from "@gnu-taler/taler-util";
|
||||
@ -199,7 +198,6 @@ export enum WalletApiOperation {
|
||||
GenerateDepositGroupTxId = "generateDepositGroupTxId",
|
||||
CreateDepositGroup = "createDepositGroup",
|
||||
SetWalletDeviceId = "setWalletDeviceId",
|
||||
WithdrawFakebank = "withdrawFakebank",
|
||||
ImportDb = "importDb",
|
||||
ExportDb = "exportDb",
|
||||
PreparePeerPushCredit = "preparePeerPushCredit",
|
||||
@ -934,17 +932,6 @@ export type TestPayOp = {
|
||||
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.
|
||||
*/
|
||||
@ -1040,7 +1027,6 @@ export type ForceRefreshOp = {
|
||||
export type WalletOperations = {
|
||||
[WalletApiOperation.InitWallet]: InitWalletOp;
|
||||
[WalletApiOperation.GetVersion]: GetVersionOp;
|
||||
[WalletApiOperation.WithdrawFakebank]: WithdrawFakebankOp;
|
||||
[WalletApiOperation.PreparePayForUri]: PreparePayForUriOp;
|
||||
[WalletApiOperation.SharePayment]: SharePaymentOp;
|
||||
[WalletApiOperation.PreparePayForTemplate]: PreparePayForTemplateOp;
|
||||
|
@ -1492,46 +1492,6 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
||||
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: {
|
||||
return await ws.cryptoApi.hashString({ str: "hello world" });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user