diff --git a/test.js b/test.js index 7b1a7e03f..92a899b93 100644 --- a/test.js +++ b/test.js @@ -138,9 +138,26 @@ function validateHallmarks(hallmark) { let unixTimestamp = Math.round(Date.now() / 1000) - 60; let chainBlocks = {} - const passedTimestamp = process.argv[3] ? Math.floor(new Date(process.argv[3]) / 1000) : undefined + + function parseTimestampArg(arg) { + if (!arg) return undefined; + // Accept pure numeric input as unix seconds or milliseconds + if (/^\d+$/.test(arg)) { + const num = Number(arg); + if (!Number.isFinite(num)) return undefined; + // 13+ digits -> milliseconds, else assume seconds + return num > 1e12 ? Math.floor(num / 1000) : num; + } + // Fallback to Date string parsing (e.g., YYYY-MM-DD) + const d = new Date(arg); + const ms = d.getTime(); + if (!Number.isFinite(ms)) return undefined; + return Math.floor(ms / 1000); + } + + const passedTimestamp = parseTimestampArg(process.argv[3]); if (passedTimestamp !== undefined) { - unixTimestamp = Number(passedTimestamp) + unixTimestamp = passedTimestamp // other chains than evm will fail to get block at timestamp try {