Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Fix condition in confirmation code generation. Fixes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
phahulin committed Mar 6, 2018
1 parent cf78f3b commit f9ce4e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web-dapp/server-lib/generate_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function generate_code() {
continue;
}
code += config.code_symbols[b%config.code_symbols.length];

if (code.length >= config.code_length) {
break;
}
}
} while (code.length < config.code_length);

Expand Down
22 changes: 22 additions & 0 deletions web-dapp/test/server/generate_code.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const generate_code = require('../../server-lib/generate_code');
const config = require('../../server-config');

const TRIES = 1e4;

describe('Confirmation code', () => {
it('cc length should be equal to the one in config', () => {
var pass = true;

for (let i = 0; i < TRIES; i++) {
let code = generate_code();
if (code.length !== config.code_length) {
pass = false;
break;
}
}

return expect(pass).toEqual(true);
});
});

0 comments on commit f9ce4e7

Please sign in to comment.