Skip to content

Commit

Permalink
feat(e2e): improve node sync progress monitoring
Browse files Browse the repository at this point in the history
- Add basic input validation for node URL
- Add sync progress percentage to status updates
- Simplify logging format for better readability
  • Loading branch information
wojciechos committed Nov 7, 2024
1 parent fc4f551 commit f06a5e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions e2e/tester/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { RpcProvider } from "starknet";

if (!process.argv[2]) {
console.error("Error: Node URL is required");
process.exit(1);
}

const node = new RpcProvider({ nodeUrl: process.argv[2] });
const timeout = parseInt(process.argv[3], 10);
const targetBlockNumber = parseInt(process.argv[4], 10);
Expand Down Expand Up @@ -56,10 +61,11 @@ async function syncNode() {
const elapsedMinutes = (Date.now() - startTime) / 1000 / 60;
const blocksSynced = currentBlock.block_number - lastBlockNumber;

// Progress update
// Progress update with completion percentage
if (currentBlock.block_number > lastBlockNumber) {
const speed = blocksSynced / elapsedMinutes;
log(`↑ Block ${currentBlock.block_number} | +${blocksSynced} | ${speed.toFixed(1)} blocks/min`);
const progress = ((currentBlock.block_number / targetBlockNumber) * 100).toFixed(1);
log(`↑ Block ${currentBlock.block_number} | ${progress}% | ${speed.toFixed(1)} blocks/min`);
lastBlockNumber = currentBlock.block_number;
lastBlockTime = Date.now();
}
Expand Down

0 comments on commit f06a5e7

Please sign in to comment.