fix comments and add new account test

This commit is contained in:
Karol Wypchlo 2021-05-24 17:07:37 +02:00
parent a2f7b7581a
commit 175ee075c7
1 changed files with 9 additions and 7 deletions

View File

@ -50,13 +50,19 @@ async function skylinkSubdomainCheck(done) {
return genericAccessCheck("skylink_via_subdomain", url, done); return genericAccessCheck("skylink_via_subdomain", url, done);
} }
// skylinkSubdomainCheck returns the result of downloading the hard coded link via subdomain // handshakeSubdomainCheck returns the result of downloading the skylink via handshake domain
async function handshakeSubdomainCheck(done) { async function handshakeSubdomainCheck(done) {
const url = await skynetClient.getHnsUrl("note-to-self", { subdomain: true }); const url = await skynetClient.getHnsUrl("note-to-self", { subdomain: true });
return genericAccessCheck("hns_via_subdomain", url, done); return genericAccessCheck("hns_via_subdomain", url, done);
} }
// handshakeSubdomainCheck returns the result of accessing account dashboard website
async function accountWebsiteCheck(done) {
return genericAccessCheck("account_website", process.env.SKYNET_DASHBOARD_URL, done);
}
// accountHealthCheck returns the result of accounts service health checks
async function accountHealthCheck(done) { async function accountHealthCheck(done) {
const time = process.hrtime(); const time = process.hrtime();
const data = { up: false }; const data = { up: false };
@ -75,11 +81,7 @@ async function accountHealthCheck(done) {
data.ip = error?.response?.ip ?? null; data.ip = error?.response?.ip ?? null;
} }
done({ done({ name: "accounts", time: calculateElapsedTime(time), ...data });
name: "account_health",
time: calculateElapsedTime(time),
...data,
});
} }
async function genericAccessCheck(name, url, done) { async function genericAccessCheck(name, url, done) {
@ -105,7 +107,7 @@ async function genericAccessCheck(name, url, done) {
const checks = [uploadCheck, websiteCheck, downloadCheck, skylinkSubdomainCheck, handshakeSubdomainCheck]; const checks = [uploadCheck, websiteCheck, downloadCheck, skylinkSubdomainCheck, handshakeSubdomainCheck];
if (process.env.ACCOUNTS_ENABLED) { if (process.env.ACCOUNTS_ENABLED) {
checks.push(accountHealthCheck); checks.push(accountHealthCheck, accountWebsiteCheck);
} }
module.exports = checks; module.exports = checks;