start to split into node commonjs style modules

- no longer is the global Bitcoin used for modules
- cleaner and more maintainable code
- add more tests
This commit is contained in:
Roman Shtylman 2013-02-17 00:39:15 -05:00
commit 0faac29134
35 changed files with 3401 additions and 3169 deletions

24
test/integer.js Normal file
View file

@ -0,0 +1,24 @@
var assert = require('assert');
var BigInteger = require('../').BigInteger;
var bytesToHex = require('../').convert.bytesToHex;
test('toByteArraySigned', function() {
function hex(num) {
var bytes = BigInteger.valueOf(num).toByteArraySigned();
var hex = bytesToHex(bytes);
return '0x' + hex;
}
assert.equal(hex( 0), '0x');
assert.equal(hex( 1), '0x01');
assert.equal(hex(-1), '0x81');
assert.equal(hex( 127), '0x7f');
assert.equal(hex(-127), '0xff');
assert.equal(hex( 255), '0x00ff');
assert.equal(hex(-255), '0x80ff');
assert.equal(hex( 16300), '0x3fac');
assert.equal(hex(-16300), '0xbfac');
assert.equal(hex( 62300), '0x00f35c');
assert.equal(hex(-62300), '0x80f35c');
});