Skip to content

Commit b3a9394

Browse files
committed
polish
1 parent 91d8de3 commit b3a9394

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apps/entropy-tester/src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ function loadConfig(configPath: string): LoadedConfig[] {
3838
const contracts = Object.values(DefaultStore.entropy_contracts).filter((contract) => (
3939
contract.chain.getId() == config['chain-id']
4040
))
41-
if (contracts.length !== 1) {
42-
throw new Error(`Can not find the contract id ${config['chain-id']}, check contract manager store.`)
41+
if (contracts.length === 0) {
42+
throw new Error(`Can not find the contract for chain ${config['chain-id']}, check contract manager store.`)
43+
}
44+
if (contracts.length > 1) {
45+
throw new Error(`Multiple contracts found for chain ${config['chain-id']}, check contract manager store.`)
4346
}
4447
loadedConfigs.push({ contract: contracts[0], interval })
4548
}
@@ -63,7 +66,7 @@ async function testLatency(
6366
// Read the sequence number for the request from the transaction events.
6467
const sequenceNumber =
6568
parseInt(requestResponse.events.RequestedWithCallback.returnValues.sequenceNumber);
66-
logger.info({ sequence: sequenceNumber, txHash: requestResponse.transactionHash }, `Request submitted`);
69+
logger.info({ sequenceNumber, txHash: requestResponse.transactionHash }, `Request submitted`);
6770

6871
const startTime = Date.now();
6972

@@ -75,11 +78,11 @@ async function testLatency(
7578

7679
if (parseInt(request.sequenceNumber) === 0) { // 0 means the request is cleared
7780
const endTime = Date.now();
78-
logger.info({ sequence: sequenceNumber, latency: endTime - startTime }, `Successful callback`);
81+
logger.info({ sequenceNumber, latency: endTime - startTime }, `Successful callback`);
7982
break;
8083
}
8184
if (Date.now() - startTime > 60000) {
82-
logger.error({ sequence: sequenceNumber }, "Timeout: 60s passed without the callback being called");
85+
logger.error({ sequenceNumber }, "Timeout: 60s passed without the callback being called");
8386
break;
8487
}
8588
}
@@ -134,7 +137,6 @@ yargs(hideBin(process.argv))
134137
}
135138
});
136139
await Promise.all(promises);
137-
138140
}
139141
})
140142
.demandCommand()

0 commit comments

Comments
 (0)