Skip to content

Commit

Permalink
Merge pull request #262 from multiparty/test
Browse files Browse the repository at this point in the history
Test Cases created with Jest (add/sub/mult/div)
  • Loading branch information
Snafkin547 authored Apr 5, 2024
2 parents 2c6fdd9 + 63379c4 commit 69e5e29
Show file tree
Hide file tree
Showing 17 changed files with 14,322 additions and 4,750 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ jobs:
with:
node-version: '20'
- name: Install dependencies
run: npm ci
run: npm ci

- name: Run Jest Tests
run: npx jest --coverage --runInBand tests/regr-tests
2 changes: 1 addition & 1 deletion dist/jiff-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ module.exports = function (jiffClient) {
* @memberof handlers
*/
jiffClient.handlers.connected = function () {
console.log('Connected!', jiffClient.id); // TODO: remove debugging

jiffClient.initialization_counter++;

if (jiffClient.secret_key == null && jiffClient.public_key == null) {
Expand Down
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.ts$': 'ts-jest'
},
moduleFileExtensions: ['ts', 'js', 'json', 'node']
};
4 changes: 4 additions & 0 deletions lib/jiff-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ function JIFFClient(hostname, computation_id, options) {
}
};

this.disconnect = async function () {
await this.socket.safe_disconnect(true);
};

// Connect when all is done
if (options.autoConnect !== false) {
this.connect();
Expand Down
15 changes: 15 additions & 0 deletions lib/server/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,19 @@ module.exports = function (JIFFServer) {
});
});
};
JIFFServer.prototype.closeAllSockets = function () {
var jiff = this;

if (jiff.io) {
const socketIds = Object.keys(jiff.socketMaps.computationId);
socketIds.forEach(function (socketId) {
var socket = jiff.io.sockets.connected[socketId];
if (socket) {
socket.disconnect(true);
}
});

jiff.io.close(); // Optionally close the entire socket.io server
}
};
};
Loading

0 comments on commit 69e5e29

Please sign in to comment.