fix: prevent immediate run of wallet recovery on cron script
Description
When running cron, the two wallet recovery tests would run immediately
and not be awaited (Promises are eager in js)
Motivation and Context
Minor fix
How Has This Been Tested?
Script run and tests did not immediately start
@@ -81,17 +81,17 @@ async function run(options = {}) {
process: wallet.ps,
outputStream: logfile,
onData: (data) => {
- let successLog = data.match(RECOVERY_COMPLETE_REGEXP);
- let recoveredAmount = data.match(RECOVERY_WORTH_REGEXP);
- if (successLog && recoveredAmount) {
- let recoveredAmount = parseInt(recoveredAmount[1]);
- if (recoveredAmount[2] === "T") {
+ let scannedMatch = data.match(RECOVERY_COMPLETE_REGEXP);
+ let recoveredAmountMatch = data.match(RECOVERY_WORTH_REGEXP);
+ if (scannedMatch && recoveredAmountMatch) {
+ let recoveredAmount = parseInt(recoveredAmountMatch[1]);
+ if (recoveredAmountMatch[2] === "T") {
// convert to micro tari
recoveredAmount *= 1000000;
}
return {
- height: parseInt(height[1]),
- recoveredAmount: parseInt(recoveredAmount[1]),
+ numScanned: parseInt(scannedMatch[1]),
+ recoveredAmount,
};
}
@@ -114,13 +114,13 @@ async function run(options = {}) {
await wallet.stop();
- const block_rate = recoveryResult.height / timeDiffMinutes;
+ const scannedRate = recoveryResult.numScanned / timeDiffMinutes;
return {
identity: id,
- height: recoveryResult.height,
+ numScanned: recoveryResult.numScanned,
timeDiffMinutes,
- blockRate: block_rate.toFixed(2),
+ scannedRate: scannedRate.toFixed(2),
recoveredAmount: recoveryResult.recoveredAmount,
};
} catch (err) {
