mirror of https://github.com/trezor/trezor-wallet
parent
6d790d9e31
commit
d4a19b5133
@ -1,45 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`eth utils calcGasPrice 1`] = `"89090990901"`;
|
|
||||||
|
|
||||||
exports[`eth utils decimalToHex 1`] = `"0"`;
|
|
||||||
|
|
||||||
exports[`eth utils decimalToHex 2`] = `"1"`;
|
|
||||||
|
|
||||||
exports[`eth utils decimalToHex 3`] = `"2"`;
|
|
||||||
|
|
||||||
exports[`eth utils decimalToHex 4`] = `"64"`;
|
|
||||||
|
|
||||||
exports[`eth utils decimalToHex 5`] = `"2540be3ff"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 1`] = `"9999999999"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 2`] = `"100"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 3`] = `"2"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 4`] = `"1"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 5`] = `"0"`;
|
|
||||||
|
|
||||||
exports[`eth utils hexToDecimal 6`] = `"null"`;
|
|
||||||
|
|
||||||
exports[`eth utils padLeftEven 1`] = `"02540be3ff"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 1`] = `"0x02540be3ff"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 2`] = `"0x01"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 3`] = `"0x02"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 4`] = `"0x0100"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 5`] = `"0x0999"`;
|
|
||||||
|
|
||||||
exports[`eth utils sanitizeHex 6`] = `""`;
|
|
||||||
|
|
||||||
exports[`eth utils strip 1`] = `""`;
|
|
||||||
|
|
||||||
exports[`eth utils strip 2`] = `"02540be3ff"`;
|
|
||||||
|
|
||||||
exports[`eth utils strip 3`] = `"02540be3ff"`;
|
|
@ -1,53 +1,44 @@
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as ethUtils from '../ethUtils';
|
import * as utils from '../ethUtils';
|
||||||
|
|
||||||
describe('eth utils', () => {
|
describe('eth utils', () => {
|
||||||
it('decimalToHex', () => {
|
it('decimalToHex', () => {
|
||||||
const input = [0, 1, 2, 100, 9999999999];
|
expect(utils.decimalToHex(0)).toBe('0');
|
||||||
|
expect(utils.decimalToHex(1)).toBe('1');
|
||||||
input.forEach((entry) => {
|
expect(utils.decimalToHex(2)).toBe('2');
|
||||||
expect(ethUtils.decimalToHex(entry)).toMatchSnapshot();
|
expect(utils.decimalToHex(100)).toBe('64');
|
||||||
});
|
expect(utils.decimalToHex(9999999999)).toBe('2540be3ff');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: decimal as string ?????
|
||||||
it('hexToDecimal', () => {
|
it('hexToDecimal', () => {
|
||||||
const input = ['2540be3ff', '64', '2', '1', '0', ''];
|
expect(utils.hexToDecimal('2540be3ff')).toBe('9999999999');
|
||||||
|
expect(utils.hexToDecimal(64)).toBe('100');
|
||||||
input.forEach((entry) => {
|
expect(utils.hexToDecimal(2)).toBe('2');
|
||||||
expect(ethUtils.hexToDecimal(entry)).toMatchSnapshot();
|
expect(utils.hexToDecimal(1)).toBe('1');
|
||||||
});
|
expect(utils.hexToDecimal(0)).toBe('0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('padLeftEven', () => {
|
it('padLeftEven', () => {
|
||||||
const input = ['2540be3ff'];
|
expect(utils.padLeftEven('2540be3ff')).toBe('02540be3ff');
|
||||||
|
|
||||||
input.forEach((entry) => {
|
|
||||||
expect(ethUtils.padLeftEven(entry)).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sanitizeHex', () => {
|
it('sanitizeHex', () => {
|
||||||
const input = ['0x2540be3ff', '1', '2', '100', '999', ''];
|
expect(utils.sanitizeHex('0x2540be3ff')).toBe('0x02540be3ff');
|
||||||
|
expect(utils.sanitizeHex('1')).toBe('0x01');
|
||||||
input.forEach((entry) => {
|
expect(utils.sanitizeHex('2')).toBe('0x02');
|
||||||
expect(ethUtils.sanitizeHex(entry)).toMatchSnapshot();
|
expect(utils.sanitizeHex('100')).toBe('0x0100');
|
||||||
|
expect(utils.sanitizeHex('999')).toBe('0x0999');
|
||||||
|
expect(utils.sanitizeHex('')).toBe('');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('strip', () => {
|
it('strip', () => {
|
||||||
const input = ['0x', '0x2540be3ff', '2540be3ff'];
|
expect(utils.strip('0x')).toBe('');
|
||||||
|
expect(utils.strip('0x2540be3ff')).toBe('02540be3ff');
|
||||||
input.forEach((entry) => {
|
expect(utils.strip('2540be3ff')).toBe('02540be3ff');
|
||||||
expect(ethUtils.strip(entry)).toMatchSnapshot();
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('calcGasPrice', () => {
|
|
||||||
const input = [{ price: new BigNumber(9898998989), limit: '9' }];
|
|
||||||
|
|
||||||
input.forEach((entry) => {
|
it('calculate gas price', () => {
|
||||||
expect(ethUtils.calcGasPrice(entry.price, entry.limit)).toMatchSnapshot();
|
expect(utils.calcGasPrice(new BigNumber(9898998989), 9)).toBe('89090990901');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in new issue