Skip to content

Commit 90728a8

Browse files
committed
fixup! feat(cardano-services): implements rabbitmq new interface
1 parent 9def59e commit 90728a8

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

packages/cardano-services/test/load/load.test.ts

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ describe('load', () => {
141141
wallet = await getWallet();
142142
({ address } = (await firstValueFrom(wallet.addresses$))[0]);
143143

144+
logger.debug('Waiting to settle wallet status');
144145
await firstValueFrom(wallet.syncStatus.isSettled$.pipe(filter((isSettled) => isSettled)));
146+
logger.debug('Wallet status settled');
145147
};
146148

147149
const waitForTxInBlockchain = (txId: Cardano.TransactionId) =>
@@ -164,9 +166,9 @@ describe('load', () => {
164166
});
165167

166168
logger.info(`Fragmentation tx: ${tx.hash}`);
167-
168169
await wallet.submitTx(await wallet.finalizeTx(tx));
169170
await waitForTxInBlockchain(tx.hash);
171+
logger.info('Fragmentation completed');
170172
};
171173

172174
if (options.directlyToOgmios) await fragment();
@@ -220,50 +222,61 @@ describe('load', () => {
220222
afterEach(stopWorker);
221223

222224
const performTest = async (options: TestOptions) => {
223-
const { directlyToOgmios, withRunningWorker } = options;
225+
const { directlyToOgmios, parallel, withRunningWorker } = options;
224226
const submitPromises: Promise<void>[] = [];
225227
const txIds: Cardano.TransactionId[] = [];
226228
let timeAfterWorkerStarted = 0;
227229
let timeBeforeSubmitTxs = 0;
228230

229-
await fragmentWhenRequired(options);
231+
try {
232+
logger.debug(`Starting test with options: ${JSON.stringify({ directlyToOgmios, parallel, withRunningWorker })}`);
230233

231-
const startWorkerForTest = async () => {
232-
if (!directlyToOgmios) await startWorker(options);
233-
timeAfterWorkerStarted = Date.now();
234-
};
234+
await fragmentWhenRequired(options);
235235

236-
const submitTransactions = async () => {
237-
timeBeforeSubmitTxs = Date.now();
238-
for (let i = 0; i < env.TRANSACTIONS_NUMBER; ++i) {
239-
const coins = 1_000_000n + 1000n * BigInt(i);
240-
const tx = await wallet.initializeTx({ outputs: new Set([{ address, value: { coins } }]) });
236+
const startWorkerForTest = async () => {
237+
if (!directlyToOgmios) await startWorker(options);
238+
timeAfterWorkerStarted = Date.now();
239+
};
241240

242-
submitPromises.push(wallet.submitTx(await wallet.finalizeTx(tx)));
243-
txIds.push(tx.hash);
241+
const submitTransactions = async () => {
242+
timeBeforeSubmitTxs = Date.now();
243+
for (let i = 0; i < env.TRANSACTIONS_NUMBER; ++i) {
244+
const coins = 1_000_000n + 1000n * BigInt(i);
245+
const tx = await wallet.initializeTx({ outputs: new Set([{ address, value: { coins } }]) });
246+
247+
submitPromises.push(wallet.submitTx(await wallet.finalizeTx(tx)));
248+
txIds.push(tx.hash);
249+
}
250+
};
251+
252+
if (withRunningWorker) {
253+
await startWorkerForTest();
254+
await submitTransactions();
255+
} else {
256+
await submitTransactions();
257+
await startWorkerForTest();
244258
}
245-
};
246259

247-
if (withRunningWorker) {
248-
await startWorkerForTest();
249-
await submitTransactions();
250-
} else {
251-
await submitTransactions();
252-
await startWorkerForTest();
253-
}
260+
await Promise.all(submitPromises);
261+
const timeAfterTxsInMempool = Date.now();
254262

255-
await Promise.all(submitPromises);
256-
const timeAfterTxsInMempool = Date.now();
263+
await Promise.all(txIds.map((txId) => waitForTxInBlockchain(txId)));
257264

258-
await Promise.all(txIds.map((txId) => waitForTxInBlockchain(txId)));
265+
testReports.push({
266+
...options,
267+
timeAfterTxsInBlockchain: Date.now(),
268+
timeAfterTxsInMempool,
269+
timeAfterWorkerStarted,
270+
timeBeforeSubmitTxs
271+
});
259272

260-
testReports.push({
261-
...options,
262-
timeAfterTxsInBlockchain: Date.now(),
263-
timeAfterTxsInMempool,
264-
timeAfterWorkerStarted,
265-
timeBeforeSubmitTxs
266-
});
273+
logger.debug(`Completed test with options: ${JSON.stringify({ directlyToOgmios, parallel, withRunningWorker })}`);
274+
} catch (error) {
275+
logger.error(
276+
`Failed test with options: ${JSON.stringify({ directlyToOgmios, parallel, withRunningWorker })}`,
277+
error
278+
);
279+
}
267280
};
268281

269282
describe('directly to ogmios', () => {

0 commit comments

Comments
 (0)