diff --git a/.travis.yml b/.travis.yml index 381c985..63f16d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: node_js node_js: + - 0.10 + - 0.8 + - 0.6 - 0.4 - - 0.6 \ No newline at end of file diff --git a/lib/objectid.js b/lib/objectid.js index 9d3953b..cd94b2c 100644 --- a/lib/objectid.js +++ b/lib/objectid.js @@ -11,7 +11,7 @@ module.exports = ObjectId // from docs: This is the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, // or the virtual machine id. -var machineHash = crypto.createHash('md5').update(os.hostname()).digest('binary') +var machineHash = crypto.createHash('md5').update(os.hostname()).digest() // Pre-cache the machine hash / pid var machineAndPid = [ @@ -92,4 +92,4 @@ try { } return buffer } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 9126371..34bdb4d 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,9 @@ "nodeunit": "0.6.4" }, "scripts": { - "test": "node_modules/.bin/nodeunit test/bson-test.js test/mongo-test.js" + "test": "node_modules/.bin/nodeunit test/bson-test.js test/mongo-test.js test/objectid.js" }, "engines": { "node": ">=0.4.0" } -} \ No newline at end of file +} diff --git a/test/objectid.js b/test/objectid.js new file mode 100644 index 0000000..1a32c06 --- /dev/null +++ b/test/objectid.js @@ -0,0 +1,11 @@ +var BSON = require('../buffalo') + +module.exports = { + "machine id part of ObjectID is not zero": function(test) { + var objid = new BSON.ObjectId(); + test.ok(!(objid.bytes[4] == 0x00 && + objid.bytes[5] == 0x00 && + objid.bytes[6] == 0x00)) + test.done() + }, +}