This commit is contained in:
psihius committed 2018-04-19 23:33:27 +03:00
commit bf9886d7ee
2 files changed
+20 -13

No files matched your search

+2 -3
View File
@@ -638,7 +638,7 @@ function instanceManagement() {
hash: modHashes[i].hash, hash: modHashes[i].hash,
} }
needle.post(config.masterIP + ":" + config.masterPort + '/api/checkMod', payload, function (err, response, body) { needle.post(config.masterIP + ":" + config.masterPort + '/api/checkMod', payload, function (err, response, body) {
if(err) throw err // Unable to contact master server! Please check your config.json. if(err) console.log(new Error("Unable to contact master server! Please check your config.json."));
if(response && body && body == "found") { if(response && body && body == "found") {
console.log("master has mod"); console.log("master has mod");
} else if (response && body && typeof body == "string") { } else if (response && body && typeof body == "string") {
@@ -649,8 +649,7 @@ function instanceManagement() {
// response.body is a string which is a modName.zip // response.body is a string which is a modName.zip
var req = request.post("http://"+config.masterIP + ":" + config.masterPort + '/api/uploadMod', function (err, resp, body) { var req = request.post("http://"+config.masterIP + ":" + config.masterPort + '/api/uploadMod', function (err, resp, body) {
if (err) { if (err) {
console.log('Error!'); console.log(new Error("Unable to contact master server! Please check your config.json."));
throw err
} else { } else {
console.log('URL: ' + body); console.log('URL: ' + body);
} }
+18 -10
View File
@@ -13,24 +13,32 @@ describe("researchSync/index.js", ()=>{
let reSync = new researchSync({}, function(){}); let reSync = new researchSync({}, function(){});
let obj1 = { let obj1 = {
a:[true, 0], a:{researched: true, level: 0},
b:[true, 0], b:{researched: true, level: 0},
c:[false, 0], c:{researched: false, level: 0},
d:[false, 10], d:{researched: false, level: 10},
}; };
let obj2 = { let obj2 = {
a:[true, 0], a:{researched: true, level: 0},
b:[true, 1], b:{researched: true, level: 1},
c:[false, 0], c:{researched: false, level: 0},
e:[false, 50], e:{researched: false, level: 50},
}; };
assert(typeof reSync.filterResearchDiff == "function"); assert(typeof reSync.filterResearchDiff == "function");
let diffResult = reSync.filterResearchDiff(obj1, obj2); let diffResult = reSync.filterResearchDiff(obj1, obj2);
assert(diffResult.a === undefined); assert(diffResult.a === undefined);
assert(diffResult.b === [true, 1]);
assert(diffResult.b !== undefined);
assert.equal(diffResult.b.researched, true);
assert.equal(diffResult.b.level, 1);
assert(diffResult.d === undefined); assert(diffResult.d === undefined);
assert(diffResult.e === [false, 50]);
assert(diffResult.e !== undefined);
assert.equal(diffResult.e.researched, false);
assert.equal(diffResult.e.level, 50);
}); });
it(".pollResearch() dumps a long Lua command", ()=>{ it(".pollResearch() dumps a long Lua command", ()=>{
let reSync = new researchSync({}, io); let reSync = new researchSync({}, io);