solidity/utils.toHex.js
Marek Kotewicz 72dc1c76fd Squashed 'libjsqrc/ethereumjs/' changes from 2a0b46a..d5d2115
d5d2115 example contract using array, fixed #185
21ed235 removed connection keep-alive
c44fe01 version 0.7.1
d9b785e fixed #248
490dde5 fixed encoding/decoding strings, #249
b3f5d09 fixed long bytes dynamic decoding/encoding, #249
d097821 small filter improvement
d59b1cd removed xhr from browser
42b6e9d version 0.7.0
fe6defd gulp
44dcd24 set connection keepalive
2b17c0f gulpfile changes
4a46c73 Merge pull request #228 from ethereum/strings
93c8006 tests for encoding and decoding prematurely terminated strings and strings containing internal zeros
7dd44e7 Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings
390a9ff Merge branch 'develop' into strings
bcd9cfb updated deps, removed unused karma
ef15fc1 Merge pull request #244 from ethereum/allevents
6f74d57 Merge branch 'develop' into allevents
7aca17e Merge branch 'develop' into allevents
c5ee34d fix for optional event parameters
8170a0a Merge pull request #245 from ethereum/filterInstantWatch
76a094c fixed all issues noted by marek
d78b512 add possible callback to filters
e1b17a9 re-build develop
af9c027 all events filter
b270616 version 0.6.1
c47d6a8 gulp
7cf7cf3 map file
6da1d3e gulp
450042e Update eth.js
3951286 Added sendRawTransaction
323b529 merged develop
16ffdf6 merged master
ecf0a2c changed | to Math.floor
d2b5ba2 Merge pull request #239 from ethereum/mistFixes
9e6bf9d removed browser XHR
9061116 fixed build issues in formatInputDynamicBytes
0e3b29c fixed coverage issue
d51e9a2 merged latest develop
f0247aa made meteor package available on the server side as well
e97c5f5 fixed and tested meteor package init
3e49f56 add currentProvidor and mist fixes
bd6d9ba merged develop
7b730b1 Merge branch 'strings' of github.com:ethereum/web3.js into strings
cc533d9 fixed bytes wrong encoding
8c6f976 Merge branch 'develop' into strings
7c970e3 add bytes32 test with leading 0
9c7f7bb re-add .map files
189484f add extra int tests
73cc711 Merge branch 'develop' into strings
fa3239f abi string type, fixes #216, #218, #219

git-subtree-dir: libjsqrc/ethereumjs
git-subtree-split: d5d2115bf9ad07a736a189e1022b7d3a549e4006
2015-07-01 14:36:10 +02:00

46 lines
2.0 KiB
JavaScript

var chai = require('chai');
var utils = require('../lib/utils/utils');
var BigNumber = require('bignumber.js');
var assert = chai.assert;
var tests = [
{ value: 1, expected: '0x1' },
{ value: '1', expected: '0x1' },
{ value: '0x1', expected: '0x1'},
{ value: '15', expected: '0xf'},
{ value: '0xf', expected: '0xf'},
{ value: -1, expected: '-0x1'},
{ value: '-1', expected: '-0x1'},
{ value: '-0x1', expected: '-0x1'},
{ value: '-15', expected: '-0xf'},
{ value: '-0xf', expected: '-0xf'},
{ value: '0x657468657265756d', expected: '0x657468657265756d'},
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: 0, expected: '0x0'},
{ value: '0', expected: '0x0'},
{ value: '0x0', expected: '0x0'},
{ value: -0, expected: '0x0'},
{ value: '-0', expected: '0x0'},
{ value: '-0x0', expected: '0x0'},
{ value: [1,2,3,{test: 'data'}], expected: '0x5b312c322c332c7b2274657374223a2264617461227d5d'},
{ value: {test: 'test'}, expected: '0x7b2274657374223a2274657374227d'},
{ value: '{"test": "test"}', expected: '0x7b2274657374223a202274657374227d'},
{ value: 'myString', expected: '0x6d79537472696e67'},
{ value: new BigNumber(15), expected: '0xf'},
{ value: true, expected: '0x1'},
{ value: false, expected: '0x0'}
];
describe('lib/utils/utils', function () {
describe('toHex', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.strictEqual(utils.toHex(test.value), test.expected);
});
});
});
});