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

Add code coverage #187

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d61c9e
Test code coverage reporting
frederickjansen Feb 19, 2020
32a76cf
Try again with matrix expansion
frederickjansen Feb 19, 2020
82e59f8
Fix yml file
frederickjansen Feb 19, 2020
650aa23
Debug travis workspace issue
frederickjansen Feb 20, 2020
e272e65
Debug travis workspace issue
frederickjansen Feb 20, 2020
77525e6
Debug travis workspace issue
frederickjansen Feb 20, 2020
1661ba3
Debug travis workspace issue
frederickjansen Feb 20, 2020
2e683be
Debug travis workspace issue
frederickjansen Feb 20, 2020
75e59e7
Debug travis workspace issue
frederickjansen Feb 20, 2020
433d93e
Test different workspaces
frederickjansen Feb 24, 2020
f2b874b
Test different workspaces
frederickjansen Feb 24, 2020
b277f47
Try adding all jobs again
frederickjansen Feb 24, 2020
7457a2f
Remove debug code and rename jobs
frederickjansen Feb 24, 2020
36a9fb3
Try without naming jobs
frederickjansen Feb 28, 2020
c5f45aa
Add Coveralls badge
frederickjansen Feb 28, 2020
75af73a
Remove specific branch from badge
frederickjansen Feb 28, 2020
0c14001
Merge branch 'master' into coveralls
frederickjansen Mar 17, 2020
6fe5ae4
Add demo tests to coveralls
KinanBab Mar 20, 2020
d8ed0eb
Merge branch 'master' into coveralls
KinanBab Mar 20, 2020
b562cde
testing travis after_failure hook
KinanBab Mar 21, 2020
8e38dee
Improve logs in tests and dump logs in travis on failure or timeout
KinanBab Mar 21, 2020
4e8d07d
fix typo
KinanBab Mar 21, 2020
7f5bf65
Fix another typo in .dump_log.sh
KinanBab Mar 21, 2020
ab008d8
Merge branch 'master' into coveralls
frederickjansen Oct 30, 2020
03896b0
Fix Travis demo command
frederickjansen Oct 30, 2020
f6d797d
Merge branch 'master' into coveralls
gxavier38 Jun 25, 2021
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
36 changes: 36 additions & 0 deletions .dump_log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
echo "FAILED"

if [[ $DEMOS == "TRUE" ]]; then
# dump all logs marked as failed, or in .lastlog (timedout)
FAILED_LOGS=$(cat '.failedlogs')
LAST_LOG=$(cat '.lastlog')

echo "Failed logs: $FAILED_LOGS"
echo "========================="
for log in $FAILED_LOGS; do
if [[ $log != "" ]]; then
cat "Failed logs: $log"
head $log

Check warning on line 14 in .dump_log.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.dump_log.sh#L14

Double quote to prevent globbing and word splitting.
echo "----------------"
echo ""
fi
done

echo "Timed out logs: $LAST_LOG"
echo "========================="
for log in $LAST_LOG; do
if [[ $log != "" ]]; then
echo "Timedout logs:"
cat $log

Check warning on line 25 in .dump_log.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.dump_log.sh#L25

Double quote to prevent globbing and word splitting.
echo "----------------"
echo ""
fi
done
else
# dump the test suite log
if [[ TEST_SUITE == '' ]]; then
TEST_SUITE='suite'
fi
cat "tests/suite/logs/${TEST_NAME}/${TEST_SUITE}.log"
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.failedlogs
.lastlog

package-lock.json
jiffclient.vim
*.DS_Store
Expand Down
154 changes: 148 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ before_install:
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
# End submodules fix
after_failure:
- ./.dump_log.sh

node_js:
- '10'
env:
Expand All @@ -32,12 +35,151 @@ env:
- TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='comparison'
- TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='ifelse'
script:
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
- if [ "$DEMOS" == "TRUE" ]; then npm run-script test-demo -- \*; else npm run test -- "$TEST_NAME" "$TEST_SUITE"; fi
- kill %1
cache:
directories:
- node_modules
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
- if [ "$DEMOS" == "TRUE" ]; then timeout -s9 48m npm run coverage:demo -- \*; else timeout -s9 48m npm run coverage -- "$TEST_NAME" "$TEST_SUITE"; fi
- kill %1

jobs:
include:
- stage: test
env: DEMOS="TRUE"
workspaces:
create:
name: 1
paths:
- .nyc_output
- env: TEST_NAME='base' TEST_SUITE=''
workspaces:
create:
name: 2
paths:
- .nyc_output
- env: TEST_NAME='bigNumber' TEST_SUITE=''
workspaces:
create:
name: 3
paths:
- .nyc_output
- env: TEST_NAME='negativeNumber' TEST_SUITE=''
workspaces:
create:
name: 4
paths:
- .nyc_output
- env: TEST_NAME='bigNumber-negativeNumber' TEST_SUITE=''
workspaces:
create:
name: 5
paths:
- .nyc_output
- env: TEST_NAME='restAPI' TEST_SUITE=''
workspaces:
create:
name: 6
paths:
- .nyc_output
- env: TEST_NAME='bits' TEST_SUITE=''
workspaces:
create:
name: 7
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='share'
workspaces:
create:
name: 8
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='arithmetic'
workspaces:
create:
name: 9
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='constant arithmetic'
workspaces:
create:
name: 10
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='constant comparison'
workspaces:
create:
name: 11
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='comparison'
workspaces:
create:
name: 12
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint' TEST_SUITE='ifelse'
workspaces:
create:
name: 13
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='share'
workspaces:
create:
name: 14
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='arithmetic'
workspaces:
create:
name: 15
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='constant arithmetic'
workspaces:
create:
name: 16
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='constant comparison'
workspaces:
create:
name: 17
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='comparison'
workspaces:
create:
name: 18
paths:
- .nyc_output
- env: TEST_NAME='fixedpoint-negativeNumber' TEST_SUITE='ifelse'
workspaces:
create:
name: 19
paths:
- .nyc_output
- stage: report
script: npm run coverage:report
workspaces:
use:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19

notifications:
slack:
secure: DuaE/q/B/la8rNGXsn/p3owtWZmn6th1rAJUXTIUUU48OjE86ehzMD40JMLMyAty3f/NHYOPufS7//AfpaIf4cGE6/4wHcTVoLOzRv6aP7WM0SvMy1WS5QgP7ryIjciyXFczknQ+JSMcXlxQDKtMCT7wBIwQO1WrB+T8e617y575t/ofO39k9Za1NA81MlrdWxTIWTDGMo17T+Pd/zz4ImHGYoifUzXi9DdH/4Zgy9SJxWQJ3PO/5RWef4qu1mBGXdanIEd63mYjIIQh8nJLn3pvWp7rQnChmwRqURDc6hpwdPJqeWO5knqhNlu/u7/TJI985rvTOPYljXfReXdF1OEHuq+prWGhv4VbxJzTpQ9PJZ42Ac1k6nCaMCJfCphpsUL48+qgeRY9IyBoqARw4Ne8hTerc7P0T/iQxgZk8zVVahdf0C27sPD0B563gMWvFKxW41YbvHwku7CpReaCt+pcGTd77p+v0mGZGlWNv/kV6KXMBHmQXGYEdVSpscEdlFbByZKagY8lrsadyZtaAaUCdD4VRGaYCWPh/+eBsVdS94r7XRHXBceiSd3ZY093r7lMO9yGnyDwqSydL7JgncO/GxWMhsEz2vRV+bgZlLU2yo60H8Kg1jvmpVP3o0d8wfkDUyLVOkJiSDZ+LuhQZ10f1MnP3AtVrMJFEKITmqw=
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# JIFF

[![Build Status](https://travis-ci.org/multiparty/jiff.svg?branch=master)](https://travis-ci.org/multiparty/jiff)
[![Coverage Status](https://coveralls.io/repos/github/multiparty/jiff/badge.svg)](https://coveralls.io/github/multiparty/jiff)

JIFF is a JavaScript library for building applications that rely on secure multi-party computation. JIFF is built to be highly flexible with a focus on usability, with the ability to be run in the browser, on mobile phones, or via Node.js. JIFF is designed so that developers need not be familiar with MPC techniques or know the details of cryptographic protocols in order to build secure applications.

Expand Down
7 changes: 6 additions & 1 deletion demos/mpc-as-a-service/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ var options = {

return params;
}
]
],
log: function (_, label) {
if (['share', 'open', 'crypto_provider'].indexOf(label) === -1) {
console.log.apply(console, Array.from(arguments).slice(1));
}
}
}
};

Expand Down
13 changes: 13 additions & 0 deletions demos/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

mkdir -p logs

LASTLOG='.lastlog'
FAILEDLOGS='.failedlogs'

if [ "$1" == "*" ]; then
rm -f FAILEDLOGS
touch FAILEDLOGS

EXIT_CODE=0
for i in demos/*; do
if [ -f "$i/test.js" ] || [ -f "$i/test.sh" ]; then
Expand All @@ -21,7 +27,9 @@ else
TESTDIR=${1%/}
NAME=$(basename $TESTDIR)
logs="logs/${NAME}.log"

echo "Server logs at ${logs}"
echo "$logs" > $LASTLOG

if [ -f "$TESTDIR/test.sh" ]; then
# demo has custom test bash script, run it
Expand All @@ -45,6 +53,11 @@ else
EXIT_CODE=$?

kill $(ps aux | grep " ${TESTDIR}/server\.js" | awk '{ print $2}')

echo "" > $LASTLOG
if [[ $EXIT_CODE != "0" ]]; then
echo "$logs" >> $FAILEDLOGS
fi
exit "$EXIT_CODE"
fi
fi
12 changes: 11 additions & 1 deletion demos/threshold/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ var path = require('path');
var express = require('express');
var app = express();
var http = require('http').Server(app);

var JIFFServer = require('../../lib/jiff-server');
new JIFFServer(http, { logs:false });
new JIFFServer(http, {
logs: false,
hooks: {
log: function (_, label) {
if (['share', 'open', 'crypto_provider'].indexOf(label) === -1) {
console.log.apply(console, Array.from(arguments).slice(1));
}
}
}
});

// Serve static files.
app.use('/demos', express.static(path.join(__dirname, '..', '..', 'demos')));
Expand Down
7 changes: 7 additions & 0 deletions demos/web-mpc/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ var jiff_instance = new JIFFServer(http, {
socketOptions: {
pingTimeout: 1000,
pingInterval: 2000
},
hooks: {
log: function (_, label) {
if (['share', 'open', 'crypto_provider'].indexOf(label) === -1) {
console.log.apply(console, Array.from(arguments).slice(1));
}
}
}
});
jiff_instance.computationMaps.maxCount['web-mpc'] = 100000; // upper bound on how input parties can submit!
Expand Down
10 changes: 5 additions & 5 deletions lib/server/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (jiffServer) {

// initialize a party: either return an initialization message with the party id or an error message (e.g. if computation is full or requested id is taken)
jiffServer.handlers.initializeParty = function (computation_id, party_id, party_count, msg, _s1) {
jiffServer.hooks.log(jiffServer, 'initialize with ', computation_id, '-', party_id, ' #', party_count, ' : ', msg, '::', _s1);
jiffServer.hooks.log(jiffServer, 'initialize ', computation_id, '-', party_id, ' #', party_count, ' : ', msg, '::', _s1);

// s1 is reserved for server use only!
if (_s1 !== true && party_id === 's1') {
Expand Down Expand Up @@ -105,7 +105,7 @@ module.exports = function (jiffServer) {
};

jiffServer.handlers.share = function (computation_id, from_id, msg) {
jiffServer.hooks.log(jiffServer, 'share from', computation_id, '-', from_id, ' : ', msg);
jiffServer.hooks.log(jiffServer, 'share', computation_id, '-', from_id, ' : ', msg);

try {
msg = jiffServer.hooks.execute_array_hooks('beforeOperation', [jiffServer, 'share', computation_id, from_id, msg], 4);
Expand All @@ -123,7 +123,7 @@ module.exports = function (jiffServer) {
};

jiffServer.handlers.open = function (computation_id, from_id, msg) {
jiffServer.hooks.log(jiffServer, 'open from', computation_id, '-', from_id, ' : ', msg);
jiffServer.hooks.log(jiffServer, 'open', computation_id, '-', from_id, ' : ', msg);

try {
msg = jiffServer.hooks.execute_array_hooks('beforeOperation', [jiffServer, 'open', computation_id, from_id, msg], 4);
Expand All @@ -141,7 +141,7 @@ module.exports = function (jiffServer) {
};

jiffServer.handlers.crypto_provider = function (computation_id, from_id, msg) {
jiffServer.hooks.log(jiffServer, 'crypto_provider from', computation_id, '-', from_id, ':', msg);
jiffServer.hooks.log(jiffServer, 'crypto_provider', computation_id, '-', from_id, ':', msg);

try {
msg = jiffServer.hooks.execute_array_hooks('beforeOperation', [jiffServer, 'crypto_provider', computation_id, from_id, msg], 4);
Expand Down Expand Up @@ -210,7 +210,7 @@ module.exports = function (jiffServer) {
};

jiffServer.handlers.custom = function (computation_id, from_id, msg) {
jiffServer.hooks.log(jiffServer, 'custom from', computation_id, '-', from_id, ':', msg);
jiffServer.hooks.log(jiffServer, 'custom', computation_id, '-', from_id, ':', msg);

try {
msg = jiffServer.hooks.execute_array_hooks('beforeOperation', [jiffServer, 'custom', computation_id, from_id, msg], 4);
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"scripts": {
"test": "./tests/suite/test.sh",
"suite": "./tests/suite/suite.sh",
"coverage": "nyc --no-clean npm run test",
"coverage:report": "nyc report --reporter=text-lcov | coveralls",
"coverage:demo": "nyc --no-clean npm run test-demo",
"gen-docs": "jsdoc -r -c docs/jsdoc.conf.json && sed -i -e 's/lib\\/ext\\/README.md/extensions.html/g' docs/jsdoc/*.html && sed -i -e 's/lib\\/ext\\/Hooks.md/hooks.html/g' docs/jsdoc/*.html && sed -i -e 's/Hooks.md/hooks.html/g' docs/jsdoc/*.html && sed -i -e 's/CONTRIBUTING.md/CONTRIBUTING.html/g' docs/jsdoc/*.html && grep -rl \"module:jiff-client~JIFFClient#\" docs/jsdoc/*.html | xargs sed -i 'html' 's/module:jiff-client~JIFFClient#//g'",
"test-demo": "./demos/run-test.sh",
"fix-memory-limit": "cross-env LIMIT=4096 increase-memory-limit",
Expand All @@ -60,13 +63,16 @@
"devDependencies": {
"browserify": "^16.5.2",
"chai": "^4.1.2",
"coveralls": "^3.0.9",
"eslint": "^4.19.1",
"eslint-plugin-requirejs": "^2.0.1",
"express": "^4.16.3",
"jsdoc": "^3.6.3",
"marked": "^0.7.0",
"minimist": "^1.2.0",
"mocha": "^4.1.0",
"neptune-notebook": "^1.3.1"
"mocha-lcov-reporter": "^1.3.0",
"neptune-notebook": "^1.3.1",
"nyc": "^15.0.0"
}
}
11 changes: 9 additions & 2 deletions tests/suite/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ var jiffBigNumberServer = require('../../lib/ext/jiff-server-bignumber');
var jiffWebSocketServer = require('../../lib/ext/jiff-server-websockets');

var options = {
logs: true,
app: app
logs: false,
app: app,
hooks: {
log: function (_, label) {
if (['share', 'open', 'crypto_provider'].indexOf(label) === -1) {
console.log.apply(console, Array.from(arguments).slice(1));
}
}
}
};

var jiff_instance = new jiffServer(http, options);
Expand Down