diff --git a/tests/periodic-test/time-is-synchronized/index.ts b/tests/periodic-test/time-is-synchronized/index.ts index feaf44a0ed..22547f81c5 100644 --- a/tests/periodic-test/time-is-synchronized/index.ts +++ b/tests/periodic-test/time-is-synchronized/index.ts @@ -70,8 +70,8 @@ if (!templateID) { throw new Error("❌ Template ID not found in e2b.toml"); } -// sleep for 5 seconds to create a time delta -await new Promise((resolve) => setTimeout(resolve, 5000)); +// sleep for 15 seconds to create a time delta +await new Promise((resolve) => setTimeout(resolve, 15000)); try { // remove the file to make script idempotent in local testing @@ -88,15 +88,15 @@ try { console.log("ℹ️ starting command"); const localDate = new Date().getTime() / 1000; - const date = await sandbox.commands.run("date +%s"); + const date = await sandbox.commands.run("date +%s%3N"); console.log("localDate", localDate); console.log("date", date.stdout); - const dateUnix = parseInt(date.stdout); + const dateUnix = parseFloat(date.stdout) / 1000; console.log("ℹ️ comparing dates", dateUnix, localDate); - // compare the dates, should be within 1 second - if (Math.abs(dateUnix - localDate) > 1) { + // compare the dates, should be within 2 second + if (Math.abs(dateUnix - localDate) > 2) { throw new Error("❌ Date is not synchronized"); } @@ -107,8 +107,7 @@ try { } catch (e) { console.error("Error while running sandbox or commands", e); throw e; -} finally { - // delete template +} finally { // delete template const output = await streamCommandOutput("deno", [ "run", "--allow-all",