Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Cases created with Jest (add/sub/mult/div) #262

Merged
merged 58 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bd0d715
WIP: Jest
Snafkin547 Mar 20, 2024
5474c9c
test in js worked (to be ts)
Snafkin547 Mar 21, 2024
c5f3a12
test in js worked (to be ts)
Snafkin547 Mar 21, 2024
bf78eb8
test cases done
Snafkin547 Mar 21, 2024
fef86dc
WIP: but returns errors
Snafkin547 Mar 22, 2024
49a20ef
Test fails when it should
Snafkin547 Mar 22, 2024
82bc201
Test fails when it should
Snafkin547 Mar 22, 2024
e36a045
Test fails when it should
Snafkin547 Mar 22, 2024
d740b0d
test created
Snafkin547 Mar 22, 2024
495e083
jiff client retrieved
Snafkin547 Mar 26, 2024
1077492
uncommented console.log from jiff-client
Snafkin547 Mar 26, 2024
55fe1a9
uncommented console.log from jiff-client
Snafkin547 Mar 26, 2024
9fde77a
uncommented console.log from jiff-client
Snafkin547 Mar 26, 2024
318c17c
uncommented console.log from jiff-client
Snafkin547 Mar 26, 2024
1aad5a1
uncommented console.log from jiff-client-websockets
Snafkin547 Mar 26, 2024
40f9acd
removed trailing comments from tsconfig
Snafkin547 Mar 26, 2024
8146203
coverage report added
Snafkin547 Mar 26, 2024
8f9180d
One test case works but no more than that due to server not closing
Snafkin547 Mar 27, 2024
f159166
Merge branch 'master' into test
Snafkin547 Mar 28, 2024
34aa798
Trying to close socket too
Snafkin547 Mar 28, 2024
24c990d
socket
Snafkin547 Mar 28, 2024
ede15cc
Method for Socket disconnection added
Snafkin547 Mar 28, 2024
7946fc2
prettiered
Snafkin547 Mar 28, 2024
7cb4b46
Update jiff-client-websockets.js
Snafkin547 Mar 28, 2024
19684ea
retrieved console.log in initialization
Snafkin547 Mar 28, 2024
2577c7a
average and stdev added
Snafkin547 Mar 29, 2024
79fc95f
renamed dir name
Snafkin547 Mar 29, 2024
689e46c
renamed dir
Snafkin547 Mar 29, 2024
688ba4d
regr tests added
Snafkin547 Apr 1, 2024
0f7f26b
vote completed
Snafkin547 Apr 1, 2024
03808cc
renamed from voting to vote
Snafkin547 Apr 1, 2024
b32ae82
renamed
Snafkin547 Apr 1, 2024
583c84d
54 % func coverage
Snafkin547 Apr 1, 2024
54231fe
preprocess test implemented
Snafkin547 Apr 2, 2024
99ef13c
5 Test suites work fine
Snafkin547 Apr 2, 2024
ccc77ef
constified entries
Snafkin547 Apr 2, 2024
dc09b3e
array-search to array
Snafkin547 Apr 2, 2024
3471297
uncommented some test cases in array
Snafkin547 Apr 2, 2024
1ad5891
WIP: bitwise
Snafkin547 Apr 2, 2024
1482923
prettier
Snafkin547 Apr 2, 2024
8c84c8c
Some error corrected
Snafkin547 Apr 3, 2024
75ed255
Missing await added
Snafkin547 Apr 3, 2024
1ae8a07
bitwise ops (except division) done
Snafkin547 Apr 3, 2024
b121ada
map. promise modified to prmise all
Snafkin547 Apr 3, 2024
5c8228f
Promisealled client disconnection
Snafkin547 Apr 3, 2024
39bffec
array.test stopped working
Snafkin547 Apr 3, 2024
f9f3d4e
removed unnecessary wait
Snafkin547 Apr 3, 2024
48efb2d
prettiered
Snafkin547 Apr 3, 2024
bc83a3a
bitwise comp works
Snafkin547 Apr 4, 2024
db312de
name changed for bitwise euality check
Snafkin547 Apr 4, 2024
3581a78
test added to github action
Snafkin547 Apr 4, 2024
552f173
var to let
Snafkin547 Apr 4, 2024
4830b27
moved require to the top
Snafkin547 Apr 4, 2024
2640fae
Unnecessary await removed
Snafkin547 Apr 4, 2024
5bf901d
Modified test.yml of github action so it runs tests separately
Snafkin547 Apr 4, 2024
62c8855
Retrieved test run statement
Snafkin547 Apr 4, 2024
953241b
Time increased for bitwise ops
Snafkin547 Apr 4, 2024
63379c4
prettiered
Snafkin547 Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
});
});
};
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];

Check warning on line 156 in lib/server/socket.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/server/socket.js#L156

Variable Assigned to Object Injection Sink
if (socket) {
socket.disconnect(true);
}
});

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