Skip to content

Commit

Permalink
js lint
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs committed Jan 11, 2024
1 parent fd1273d commit 4c78c91
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions tf-managed/modules/snapshot-monitoring/snapshot-age-monitor.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
var assert = require('assert');
// eslint-disable-next-line @typescript-eslint/no-var-requires -- "approved" methods of resolving this lint do not work in the NR context.
var assert = require("assert");

function check_snapshot(url, genesisTime) {
var callback = function (err, response, body) {
assert.equal(response.statusCode, 200, 'Expected a 200 OK response');
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- that's how the callback works in this context.
var callback = function (_err, response, _body) {
assert.equal(response.statusCode, 200, "Expected a 200 OK response");

var snapshotName = response.url.split('/').pop();
var snapshotName = response.url.split("/").pop();
var height = snapshotName.match(/height_(\d+)/)[1];

var currentTime = Math.floor(Date.now() / 1000);
var snapshotTime = height * 30 + genesisTime;
var snapshotAgeInMinutes = (currentTime - snapshotTime) / 60;

assert(snapshotAgeInMinutes < 360, 'Expected snapshot to be less than 360 minutes old');
}
assert(
snapshotAgeInMinutes < 360,
"Expected snapshot to be less than 360 minutes old"
);
};

$http.head(url, callback)
// This variable is provided by New Relic.
// eslint-disable-next-line no-undef
$http.head(url, callback);
}

check_snapshot('https://forest-archive.chainsafe.dev/latest/calibnet/', 1667326380)
check_snapshot('https://forest-archive.chainsafe.dev/latest/mainnet/', 1598306400)
check_snapshot(
"https://forest-archive.chainsafe.dev/latest/calibnet/",
1667326380
);
check_snapshot(
"https://forest-archive.chainsafe.dev/latest/mainnet/",
1598306400
);

0 comments on commit 4c78c91

Please sign in to comment.