From 0672004cbd9de66891849ded65b04f00a2ad5804 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 19 Apr 2018 17:51:46 +0200 Subject: [PATCH 1/2] researchSync: Partially fixed failing test (it still fails) --- sharedPlugins/researchSync/index.spec.js | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sharedPlugins/researchSync/index.spec.js b/sharedPlugins/researchSync/index.spec.js index 6ca5e15b..eae51abc 100644 --- a/sharedPlugins/researchSync/index.spec.js +++ b/sharedPlugins/researchSync/index.spec.js @@ -13,24 +13,32 @@ describe("researchSync/index.js", ()=>{ let reSync = new researchSync({}, function(){}); let obj1 = { - a:[true, 0], - b:[true, 0], - c:[false, 0], - d:[false, 10], + a:{researched: true, level: 0}, + b:{researched: true, level: 0}, + c:{researched: false, level: 0}, + d:{researched: false, level: 10}, }; let obj2 = { - a:[true, 0], - b:[true, 1], - c:[false, 0], - e:[false, 50], + a:{researched: true, level: 0}, + b:{researched: true, level: 1}, + c:{researched: false, level: 0}, + e:{researched: false, level: 50}, }; assert(typeof reSync.filterResearchDiff == "function"); let diffResult = reSync.filterResearchDiff(obj1, obj2); + 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.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", ()=>{ let reSync = new researchSync({}, io); From 2111e337c9d6020ebbebbdfb3b7b2b9245ec3e09 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 19 Apr 2018 18:41:30 +0200 Subject: [PATCH 2/2] Fix crash when starting client.js without master --- client.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client.js b/client.js index d87966af..a08eb20e 100644 --- a/client.js +++ b/client.js @@ -632,7 +632,7 @@ function instanceManagement() { hash: modHashes[i].hash, } 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") { console.log("master has mod"); } else if (response && body && typeof body == "string") { @@ -643,8 +643,7 @@ function instanceManagement() { // 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) { if (err) { - console.log('Error!'); - throw err + console.log(new Error("Unable to contact master server! Please check your config.json.")); } else { console.log('URL: ' + body); }