diff options
Diffstat (limited to 'packages/taler-harness/src/harness/helpers.ts')
-rw-r--r-- | packages/taler-harness/src/harness/helpers.ts | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index 9004d4419..932854a1e 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -218,9 +218,6 @@ export async function createSimpleTestkudosEnvironment( export async function useSharedTestkudosEnvironment(t: GlobalTestState) { const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); - // FIXME: We should probably have some file to indicate that - // the previous env setup finished successfully. - const sharedDir = `/tmp/taler-harness@${process.env.USER}`; fs.mkdirSync(sharedDir, { recursive: true }); @@ -270,7 +267,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) { }); } - logger.info("setting up exchange"); + logger.info("setting up merchant"); let merchant: MerchantService; const merchantName = "testmerchant-1"; @@ -308,38 +305,59 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) { logger.info("basic setup done, starting services"); - await bank.start(); + const bankStart = async () => { + await bank.start(); - await bank.pingUntilAvailable(); + await bank.pingUntilAvailable(); + }; - await exchange.start(); - await exchange.pingUntilAvailable(); + const exchangeStart = async () => { + await exchange.start({ + skipSetup: prevSetupDone, + }); + await exchange.pingUntilAvailable(); + }; - await merchant.start(); - await merchant.pingUntilAvailable(); + const merchStart = async () => { + await merchant.start({ + skipSetup: prevSetupDone, + }); + await merchant.pingUntilAvailable(); + + if (!prevSetupDone) { + await merchant.addInstance({ + id: "default", + name: "Default Instance", + paytoUris: [getPayto("merchant-default")], + defaultWireTransferDelay: Duration.toTalerProtocolDuration( + Duration.fromSpec({ minutes: 1 }), + ), + }); + + await merchant.addInstance({ + id: "minst1", + name: "minst1", + paytoUris: [getPayto("minst1")], + defaultWireTransferDelay: Duration.toTalerProtocolDuration( + Duration.fromSpec({ minutes: 1 }), + ), + }); + } + }; - await merchant.addInstance({ - id: "default", - name: "Default Instance", - paytoUris: [getPayto("merchant-default")], - defaultWireTransferDelay: Duration.toTalerProtocolDuration( - Duration.fromSpec({ minutes: 1 }), - ), - }); + const walletStart = async () => { + return await createWalletDaemonWithClient(t, { name: "wallet" }); + }; - await merchant.addInstance({ - id: "minst1", - name: "minst1", - paytoUris: [getPayto("minst1")], - defaultWireTransferDelay: Duration.toTalerProtocolDuration( - Duration.fromSpec({ minutes: 1 }), - ), - }); + const res = await Promise.all([ + exchangeStart(), + merchStart(), + bankStart(), + walletStart(), + ]); - const { walletClient, walletService } = await createWalletDaemonWithClient( - t, - { name: "wallet" }, - ); + const walletClient = res[3].walletClient; + const walletService = res[3].walletService; console.log("setup done!"); @@ -399,7 +417,7 @@ export async function createSimpleTestkudosEnvironmentV2( bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); if (opts.additionalBankConfig) { - opts.additionalBankConfig(bank) + opts.additionalBankConfig(bank); } await bank.start(); @@ -428,7 +446,7 @@ export async function createSimpleTestkudosEnvironmentV2( } if (opts.additionalExchangeConfig) { - opts.additionalExchangeConfig(exchange) + opts.additionalExchangeConfig(exchange); } await exchange.start(); await exchange.pingUntilAvailable(); @@ -436,7 +454,7 @@ export async function createSimpleTestkudosEnvironmentV2( merchant.addExchange(exchange); if (opts.additionalMerchantConfig) { - opts.additionalMerchantConfig(merchant) + opts.additionalMerchantConfig(merchant); } await merchant.start(); await merchant.pingUntilAvailable(); |