Skip to content

Commit

Permalink
revert to skynet-js and fix running checks locally
Browse files Browse the repository at this point in the history
  • Loading branch information
kwypchlo committed Aug 19, 2022
1 parent 9a30e9c commit 33a0a3a
Show file tree
Hide file tree
Showing 5 changed files with 403 additions and 3,836 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@skynetlabs/skynet-nodejs": "^2.8.0",
"deep-object-diff": "^1.1.7",
"express": "^4.18.1",
"form-data": "^4.0.0",
Expand All @@ -14,6 +13,7 @@
"http-status-codes": "^2.2.0",
"lodash": "^4.17.21",
"lowdb": "^1.0.0",
"skynet-js": "^4.3.0",
"tus-js-client": "^3.0.0",
"write-file-atomic": "^4.0.1",
"yargs": "^17.5.1"
Expand Down
8 changes: 6 additions & 2 deletions src/checks/critical.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const FormData = require("form-data");
const { isEqual } = require("lodash");
const tus = require("tus-js-client");
const { calculateElapsedTime, getResponseContent, isPortalModuleEnabled } = require("../utils");
const { SkynetClient, stringToUint8ArrayUtf8, genKeyPairAndSeed } = require("@skynetlabs/skynet-nodejs");
const { SkynetClient, stringToUint8ArrayUtf8, genKeyPairAndSeed } = require("skynet-js");

const MODULE_BLOCKER = "b";

Expand All @@ -24,7 +24,10 @@ async function skydConfigCheck(done) {
const data = { up: false };

try {
const response = await got(`http://10.10.10.10:9980/renter`, { headers: { "User-Agent": "Sia-Agent" } }).json();
const response = await got(`http://10.10.10.10:9980/renter`, {
headers: { "User-Agent": "Sia-Agent" },
timeout: { connect: 5000 }, // timeout after 5 seconds when skyd is not available
}).json();

// make sure initial funding is set to 10SC
if (response.settings.allowance.paymentcontractinitialfunding !== "10000000000000000000000000") {
Expand All @@ -50,6 +53,7 @@ async function skydWorkersCooldownCheck(done) {
try {
const response = await got(`http://10.10.10.10:9980/renter/workers`, {
headers: { "User-Agent": "Sia-Agent" },
timeout: { connect: 5000 }, // timeout after 5 seconds when skyd is not available
}).json();

const workersCooldown =
Expand Down
10 changes: 4 additions & 6 deletions src/checks/extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const hasha = require("hasha");
const { detailedDiff } = require("deep-object-diff");
const { isEqual } = require("lodash");
const { calculateElapsedTime, ensureValidJSON, getResponseContent } = require("../utils");
const { parseSkylink } = require("@skynetlabs/skynet-nodejs");

// audioExampleCheck returns the result of trying to download the skylink
// for the Example audio file on siasky.net
Expand Down Expand Up @@ -690,7 +689,7 @@ function pdfExampleCheck(done) {
function skyBayCheck(done) {
const linkInfo = {
name: "SkyBay",
skylink: "EABkMjXzxJRpPz0eO0Or5fy2eo-rz3prdigGwRlyNd9mwA/",
skylink: "EABkMjXzxJRpPz0eO0Or5fy2eo-rz3prdigGwRlyNd9mwA",
bodyHash: "dfc0b1d3d1113254d7545d19f6118855ed9c778b",
metadata: {
filename: "skybay.html",
Expand Down Expand Up @@ -731,7 +730,7 @@ function skyBayRedirectCheck(done) {
function skyBinCheck(done) {
const linkInfo = {
name: "SkyBin",
skylink: "CAAVU14pB9GRIqCrejD7rlS27HltGGiiCLICzmrBV0wVtA/",
skylink: "CAAVU14pB9GRIqCrejD7rlS27HltGGiiCLICzmrBV0wVtA",
bodyHash: "858ff733c4cb06a80060b8a62cf303fd5a051651",
metadata: { filename: "skybin.html" },
headers: {
Expand Down Expand Up @@ -769,7 +768,7 @@ const skyGalleryMetadata = require("../fixtures/skygalleryMetadata.json");
function skyGalleryCheck(done) {
const linkInfo = {
name: "SkyGallery",
skylink: "AADW6GsQcetwDBaDYnGCSTbYjSKY743NtY1A5VRx5sj3Dg/",
skylink: "AADW6GsQcetwDBaDYnGCSTbYjSKY743NtY1A5VRx5sj3Dg",
bodyHash: skyGalleryBodyHash,
metadata: skyGalleryMetadata,
headers: {
Expand Down Expand Up @@ -1172,8 +1171,7 @@ async function skylinkVerification(done, expected, { followRedirect = true, meth
}

if (expected.metadata && expected.skylink) {
const skylink = parseSkylink(expected.skylink);
const url = `https://${process.env.PORTAL_DOMAIN}/skynet/metadata/${skylink}`;
const url = `https://${process.env.PORTAL_DOMAIN}/skynet/metadata/${expected.skylink}`;
try {
const metadata = await got(url, {
headers: { "Skynet-Api-Key": process.env.ACCOUNTS_TEST_USER_API_KEY },
Expand Down
Loading

0 comments on commit 33a0a3a

Please sign in to comment.