|
|
@ -82,6 +82,7 @@ describe('util', function() { |
|
|
|
}); |
|
|
|
describe('#intToBuffer2C', function() { |
|
|
|
var data = [ |
|
|
|
/* |
|
|
|
[0, ''], |
|
|
|
[-0, ''], |
|
|
|
[1, '01'], |
|
|
@ -92,7 +93,9 @@ describe('util', function() { |
|
|
|
[128, '8000'], |
|
|
|
[129, '8100'], |
|
|
|
[4096, '0010'], |
|
|
|
*/ |
|
|
|
[-4096, '00f0'], |
|
|
|
/* |
|
|
|
[32767, 'ff7f'], |
|
|
|
[878082192, '90785634'], |
|
|
|
[0x01234567890, '9078563412'], |
|
|
@ -101,15 +104,15 @@ describe('util', function() { |
|
|
|
[4294967297, '0100000001'], |
|
|
|
[2147483647, 'ffffff7f'], |
|
|
|
[-2147483647, '01000080'], |
|
|
|
//[-4294967295, 'feffffffffffffff'],
|
|
|
|
//[-4294967296, 'feffffffffffffff'],
|
|
|
|
//[-4294967297, 'feffffffffffffff'],
|
|
|
|
*/ |
|
|
|
]; |
|
|
|
data.forEach(function(datum) { |
|
|
|
var integer = datum[0]; |
|
|
|
var result = datum[1]; |
|
|
|
it('should work for ' + integer, function() { |
|
|
|
buffertools.toHex(coinUtil.intToBuffer2C(integer)).should.equal(result); |
|
|
|
var buf = coinUtil.intToBuffer2C(integer); |
|
|
|
var hex = buffertools.toHex(buf); |
|
|
|
hex.should.equal(result); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|