diff options
author | Florian Dold <florian@dold.me> | 2022-03-14 18:31:30 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-14 18:31:36 +0100 |
commit | 332745862e728dc5e79a424698b2736c4f2683bf (patch) | |
tree | 6617d10c145868741f751853261c9c126b6f580e /packages/taler-wallet-core/src/operations/testing.ts | |
parent | 9e7ee06ad1870339d011a0be27867cc36f94490d (diff) | |
download | wallet-core-332745862e728dc5e79a424698b2736c4f2683bf.tar.xz |
wallet: towards db-less benchmarking, some refactoring
Diffstat (limited to 'packages/taler-wallet-core/src/operations/testing.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/testing.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts index d6f0626dd..93f48fb83 100644 --- a/packages/taler-wallet-core/src/operations/testing.ts +++ b/packages/taler-wallet-core/src/operations/testing.ts @@ -74,7 +74,7 @@ function makeId(length: number): string { /** * Helper function to generate the "Authorization" HTTP header. */ -function makeAuth(username: string, password: string): string { +function makeBasicAuthHeader(username: string, password: string): string { const auth = `${username}:${password}`; const authEncoded: string = Buffer.from(auth).toString("base64"); return `Basic ${authEncoded}`; @@ -89,7 +89,7 @@ export async function withdrawTestBalance( const bankUser = await registerRandomBankUser(ws.http, bankBaseUrl); logger.trace(`Registered bank user ${JSON.stringify(bankUser)}`); - const wresp = await createBankWithdrawalUri( + const wresp = await createDemoBankWithdrawalUri( ws.http, bankBaseUrl, bankUser, @@ -119,7 +119,11 @@ function getMerchantAuthHeader(m: MerchantBackendInfo): Record<string, string> { return {}; } -async function createBankWithdrawalUri( +/** + * Use the testing API of a demobank to create a taler://withdraw URI + * that the wallet can then use to make a withdrawal. + */ +export async function createDemoBankWithdrawalUri( http: HttpRequestLibrary, bankBaseUrl: string, bankUser: BankUser, @@ -136,7 +140,7 @@ async function createBankWithdrawalUri( }, { headers: { - Authorization: makeAuth(bankUser.username, bankUser.password), + Authorization: makeBasicAuthHeader(bankUser.username, bankUser.password), }, }, ); @@ -159,7 +163,7 @@ async function confirmBankWithdrawalUri( {}, { headers: { - Authorization: makeAuth(bankUser.username, bankUser.password), + Authorization: makeBasicAuthHeader(bankUser.username, bankUser.password), }, }, ); |