2015-08-10 22:20:41 +02:00
|
|
|
|
var chai = require('chai');
|
2017-01-26 10:24:14 +01:00
|
|
|
|
var utils = require('../packages/web3-utils');
|
|
|
|
|
|
2015-08-10 22:20:41 +02:00
|
|
|
|
var assert = chai.assert;
|
|
|
|
|
|
|
|
|
|
var tests = [
|
|
|
|
|
{ value: 'myString', expected: '0x6d79537472696e67'},
|
2015-08-10 23:33:51 -04:00
|
|
|
|
{ value: 'myString\x00', expected: '0x6d79537472696e6700'},
|
|
|
|
|
{ value: '\u0003\u0000\u0000\u00005èÆÕL]\u0012|ξ\u001a7«\u00052\u0011(ÐY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076*
\bñùC1ÉUÀé2\u001aÓB',
|
|
|
|
|
expected: '0x0300000035e8c6d54c5d127c9dcebe9e1a37ab9b05321128d097590a3c100000000000006521df642ff1f5ec0c3a7aa6cea6b1e7b7f7cda2cbdf07362a85088e97f19ef94331c955c0e9321ad386428c'}
|
2015-08-10 22:20:41 +02:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
describe('lib/utils/utils', function () {
|
|
|
|
|
describe('fromAscii', function () {
|
|
|
|
|
tests.forEach(function (test) {
|
|
|
|
|
it('should turn ' + test.value + ' to ' + test.expected, function () {
|
2015-10-08 04:09:51 +02:00
|
|
|
|
assert.strictEqual(utils.fromAscii(test.value), test.expected);
|
2015-08-10 22:20:41 +02:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|