Skip to content

Commit

Permalink
ci: Added coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Zarecky committed Jan 6, 2022
1 parent bcc4a44 commit cd29b63
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: CI
env:
CI: true

on:
push:
Expand Down Expand Up @@ -33,7 +35,11 @@ jobs:
- name: Yarn install
run: yarn --frozen-lockfile
- name: Test
run: yarn test
run: yarn test --coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next')
run: yarn semantic-release
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
/dist/
TODO

# test
/coverage/

# debug
npm-debug.log*
yarn-debug.log*
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# X448-js [![GitHub license](https://img.shields.io/github/license/Iskander508/X448-js?style=flat)](https://github.com/Iskander508/X448-js/blob/master/LICENSE) [![Tests](https://github.com/Iskander508/X448-js/workflows/CI/badge.svg)](https://github.com/Iskander508/X448-js/actions) ![npm](https://img.shields.io/npm/v/x448-js) [![Monthly Downloads][downloads-img]][downloads-url]
# X448-js [![GitHub license](https://img.shields.io/github/license/Iskander508/X448-js?style=flat)](https://github.com/Iskander508/X448-js/blob/master/LICENSE) [![Tests](https://github.com/Iskander508/X448-js/workflows/CI/badge.svg)](https://github.com/Iskander508/X448-js/actions) ![npm](https://img.shields.io/npm/v/x448-js) [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]

[coveralls-url]: https://coveralls.io/github/Iskander508/X448-js?branch=master
[coveralls-img]: https://coveralls.io/repos/Iskander508/X448-js/badge.svg?branch=master&service=github
[downloads-url]: https://www.npmjs.com/package/x448-js
[downloads-img]: https://img.shields.io/npm/dm/x448-js.svg

Expand Down
22 changes: 18 additions & 4 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getPublicKey, getSharedSecret } from "./";

function random(length: number): number[] {
return Array.from({ length }, () => Math.floor(Math.random() * 256));
}

describe("X448", () => {
it("matches shared secret for 2 generated key pairs", () => {
function random(length: number): number[] {
return Array.from({ length }, () => Math.floor(Math.random() * 256));
}

const a_priv = random(56);
const b_priv = random(56);

Expand Down Expand Up @@ -66,4 +66,18 @@ describe("X448", () => {
),
);
});

it("fails with missing input", () => {
const missing: any = null;
expect(() => getPublicKey(missing)).toThrow();
expect(() => getSharedSecret(missing, random(56))).toThrow();
expect(() => getSharedSecret(random(56), missing)).toThrow();
});

it("fails with invalid size of input", () => {
expect(() => getPublicKey(random(57))).toThrow();
expect(() => getPublicKey(random(55))).toThrow();
expect(() => getSharedSecret(random(56), random(55))).toThrow();
expect(() => getSharedSecret(random(55), random(56))).toThrow();
});
});

0 comments on commit cd29b63

Please sign in to comment.