diff --git a/lib/util.js b/lib/util.js index 8a81cf1f8..213390bf8 100644 --- a/lib/util.js +++ b/lib/util.js @@ -22,7 +22,7 @@ var util = { return dest; }, randomId: function () { - return Math.random().toString(36).substr(2); + return (Math.random().toString(36) + '0000000000000000000').substr(2, 16); }, prettyError: function (msg) { if (util.debug) { diff --git a/test/server.js b/test/server.js index 9ce659d35..e40d858f6 100644 --- a/test/server.js +++ b/test/server.js @@ -206,7 +206,7 @@ describe('PeerServer', function() { }); it('should generate a 16-character ID', function() { - expect(p._generateClientId('anykey').length).to.be.within(15, 16); + expect(p._generateClientId('anykey').length).to.be(16); }); }); });