solidity/utils.fromWei.js

23 lines
1.3 KiB
JavaScript
Raw Normal View History

Squashed 'libjsqrc/ethereumjs/' changes from 7d6b35a..9926e27 9926e27 upgraded version to 0.1.0 7a44f76 add shh post formatting 27d5421 merged from ethereum again 3848d3a fixed logs 18e1367 gulp f831dde Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 27fca17 common fixes 1c9f50f changed topic to topics 8d7d00d fixed input parser test 1269731 Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 2c740b0 add filter value conversion 38f6567 fixed examples fa5d4b5 Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 8a2444b add default paramter for getBlock 2850bee fixed eth_getFilterChanges b454587 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into apiOverhaul ede88f8 Merge pull request #105 from jorisbontje/balance-example 51a075c add in-output until eth_getBlockByHash 9c0d3e3 fixed to/fromWei a0b5353 changed outputs up to storageAt c2ed233 update balance example for new api 1f6c195 fixed toBigNumber e5cc501 updated readme 4eb857e increased meteor package version c7f8373 separated formatters files 068bdd7 changed project structure ddb90c2 refactoring formatters a6110a5 common changes d3569e4 more coverage tests e2352b4 utils.js docs 344428b tests... 9fe105e fixed from decimal; 50fc611 test for utils.toBigNumber 60ae274 code comments b8505d1 common changes ccb3775 new api method names 2b17ad6 refactoring 0a995e1 common changes in utils, fixing code complexity 3f63109 fix all failing karma tests 1fd1a31 Merge branch 'develop' into apiOverhaul 0b9d450 fixed karma test 75e92c8 Merge branch 'master' into develop a869780 Merge branch 'master' into apiOverhaul 2cdf08b Merge pull request #101 from chevdor/master 437e273 Helping travis a bit... old boy! d88effa Add node 0.12 + virtual screen for browsers/karma. 743eb30 Including Karma to Travis f0da6ef Merge remote-tracking branch 'upstream/master' cbb1efe test(eth): Disable few tests b819391 fixed tests c1136a0 Merge branch 'master' into develop 1b475aa downgrade to unreachable-branch-transform 0.1.0 636fb4b updated outdated deps cf3fa10 Merge branch 'ch' 96f3076 karma 9c72d43 Merge pull request #100 from chevdor/master 96fede8 Merge pull request #98 from kumavis/develop 833b810 doc(readme): Information about Karma in the readme e46f6f1 test(utils): Add test for the toEth() function 1e0d76e Remove phantomjs af5fef0 test(karma): Add Karma support 20c4e28 Move envify and unreachable-branch-transform to normal dependencies for external browserify support. 333c3ff merged develop b07ddb4 add defualt block 024433f Merge branch 'master' into develop 601c8ab ignore for maxcomplexity warning d9d190e Merge branch 'master' into develop a05742f Add internal defaultBlock 6cd96c9 add net object 48c107e update meteor package 9c4080b made filter polling async 869bb66 add optional callback 4096fb8 merged develop 5c4a36b working on adding callbacks 30111f7 Merge pull request #87 from kumavis/develop f2029b4 Merge pull request #85 from ethers/abiString ee686b0 Move browserify transforms to package.json 4b9bc17 constants should be before (dynamic) string contents 1c136e3 merged develop aef0171 add shh topic auto transformation for filter options 37e6d11 add shh output formatters and test c03a949 add package-init.js a69c04d add version file 487e0ac mdae it a meteor package 8cf8b9e gulp fd85749 Merge pull request #81 from ethers/arraySupport fcab219 vary the length of the arrays f8db634 need to save/concat per iteration ce664d6 fix test descriptions 66196ee constants should be before array contents, fixes #30 2cd4f02 add build files 47412c3 add more tests for blocks 545de25 add more tests 2e9a411 Merge pull request #71 from frozeman/apiOverhaul 30518ae fixed complexities 84900e6 merged with solved conflicts eaef1a2 merged develop 9981b97 fixed ) 8128342 fixed small change request 5ea5be2 add deprecated transact 181f109 changed getCode to getData 1fa7fa6 toFromWei fix ee65b2c add input formatter for transactions fec54d8 add depreaction warnring to contractFromAbi 684c495 changed contract API 36ca47f Changed watch to filter for eth and shh 7fde77d add formatter b41d7b3 Merge branch 'master' into develop 5424406 Merge pull request #69 from frozeman/apiOverhaul 1e3edbb Merge branch 'develop' of https://github.com/ethereum/ethereum.js into apiOverhaul 60cda4e fixed tests 91c015e Made to/fromWei return strings instead of numbers 85c843e Merge pull request #67 from frozeman/apiOverhaul ed7d473 Removed enumerable from methods, fixed number property ce141d8 Removed circular dependencies 188e9e5 Add toWei/fromWei and isAddress 5c994ff changed most of the function names REVERT: 7d6b35a Merge branch 'master' into cpp REVERT: ea250e6 Merge commit 'be3bfb76bef1d1f113033cd9093e03a00066d5d1' into ethereumjs_timeout REVERT: c08cea1 Improvement to AZ - confirmation disabler. Fix network crash. git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 9926e27a84fe21f3e7250e7e245977a7125ddf63
2015-03-10 16:41:32 +00:00
var assert = require('assert');
var utils = require('../lib/utils/utils.js');
Squashed 'libjsqrc/ethereumjs/' changes from eceeda7..73b9ed2 73b9ed2 rename to web3 c80ede5 fixed spelling in package description 67f0a75 version 0.2.4 e2990ae web3.eth.getBlockTransactionCount accepts pending/latest/earliest params 94429ff version 0.2.3 f9a5206 more tests for web3.eth.getBalance 31e046d Merge branch 'master' into develop 5e15037 fixed formatting address b7a03cd version 0.2.2 2536888 let travis check if npm package is not broken 92aba81 merge master, gulp e6a76ff Merge branch 'master' into develop 57d9f1f removed deprecated && unused lines from contract.js 5885bfe test for #128 e53f316 tests for transaction && call 31220d5 removed deprecated code in contract.js b837667 unified asBlock from filter.js with blockNumber formatter 202a8cd #140 badge 608d211 blockNumber can be earliest f0216fb fixed #149 e213551 tests for #144 21791f2 version 0.2.1 2262276 defaultBlockNumber accepts latest && pending e01bb23 fixed #148 && fixed polling test 8c39acc merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 534e96d Merge branch 'master' of https://github.com/ethereum/ethereum.js 2f45df8 fix && tests for #147 e750fd9 fixed #147 e0d83d0 removed unecessary callformatter 9fc5575 version 0.2.0 2747f4c Merge pull request #137 from ethereum/sandbox ed2b62d add whisper, network and ethereum version aa9fc92 add whisper, network and ethereum version f4e5a99 default log formatter, improved contract test e9b5da4 updated package.js name to web3 8caf64a update package.json 07bcdb4 improved tests for contract.js, fixed few minor issues 1986c7f cleaned up web3.js 82b18c1 refactored filter.js 2133d27 filter changes in progress 0dbd68c Merge branch 'develop' into sandbox 17164be default toBlock && fromBlock is not null e928e14 Merge branch 'develop' into sandbox 1a84015 fixed events topics 0beb01f test for creating signatures a63d604 removed unused function 9d5b602 test names a1ec149 renamed few more tests cbf8ea1 test naming convention 04f0aa5 fixed filer.js complexity 722a5bc fixed eth.getTransaction.js location c065f17 Merge branch 'develop' into sandbox b78dffa small fix in filter tests 91baec2 polling tests 4f5c5fb first try to test polling f2c8a14 removed duplicate code 9f073d9 applied fixes from cpp-ethereum c01abfc add db tests b247c49 add sha3 test afd7e7b add shh tests e7304b5 add storage tests f32b8ad add runTest module to new tests c52250e add block uncle and block counts c1f5ab2 test.method.js in helpers 7df9099 moved test.utils to helpers a4e3645 Merge branch 'develop' into sandbox b3b95c5 add getBlock test abe064f add Property and passing through of RPC erro texts 0b84376 fix for otto 36fe79f another fix for otto be04c47 fixes for go otto env c7e5d0a light browser bundle 4b37137 light browser bundle without bignumber.js f13a727 add accounts test b915ceb add defaultBlock back b074a5e add check for providor async function ae76428 Merge branch 'master' into develop a34321d removed double FakeHTTPProvidor 7fb4405 add missing formatters, fixed tests 7511e4c fake providers moved to helpers directory b16982b fix for polling 126b40c fixed registering coverage on providers 2924e00 fix for toHex transforming boolean b6b809c setting up formatters for eth 99ea9cd fixed for defaultBlock formatter 33a3fc7 generic integration tests 4d1cf0b inputFormatter is an aray of functions 6b07920 add uninstall filter back 89b1ca6 first integration tests a4cf661 tests for method.js 7519fab method.js 9423b72 Merge pull request #139 from gitter-badger/gitter-badge 24a03e0 Added Gitter badge 0898669 changes in input formatters 748cda2 requestmanager tests 476023e requestmanager refactored e3faebe jsonrpc is an object cbab0ae common changes in requestmanager d408fb0 comments in requestmanager 5c1e85f requestmanager refactor in progress f604670 tests for qtsyncprovider.js 288caf3 node-sandbox, tests for httpprovider, request manager refactor in progress 8c36a10 rename getData to getCode de5de9e Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 5cdea25 Merge branch 'getCode' of https://github.com/jorisbontje/ethereum.js into getCode 3550f91 Merge pull request #122 from frozeman/apiOverhaul fb99d10 fixed meteor package 99795e3 expose bignumber.js db7092b Merge pull request #117 from ethereum/bundle_name 5bee7be changed bundle name web3 -> ethereum.js 7ca3b40 gulp 517eff9 Merge pull request #120 from dchambers/make-browserify-compatibile b032429 rename getData to getCode 768d4bf Make changes to 'gulpfile.js' reccomended by @debris. 0267e85 Use browserify's 'browser' field instead of 'envify' & 'unreachable-branch-transform to', plus always include 'bignumber.js' since it is needed in the browser. cb7c209 removed unused property 12aed56 fixed #111 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 73b9ed29c09531817df311c2d050dec6667197e7
2015-04-07 02:50:10 +00:00
describe('lib/utils/utils', function () {
Squashed 'libjsqrc/ethereumjs/' changes from 7d6b35a..9926e27 9926e27 upgraded version to 0.1.0 7a44f76 add shh post formatting 27d5421 merged from ethereum again 3848d3a fixed logs 18e1367 gulp f831dde Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 27fca17 common fixes 1c9f50f changed topic to topics 8d7d00d fixed input parser test 1269731 Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 2c740b0 add filter value conversion 38f6567 fixed examples fa5d4b5 Merge branch 'apiOverhaul' of https://github.com/frozeman/ethereum.js into apiOverhaul 8a2444b add default paramter for getBlock 2850bee fixed eth_getFilterChanges b454587 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into apiOverhaul ede88f8 Merge pull request #105 from jorisbontje/balance-example 51a075c add in-output until eth_getBlockByHash 9c0d3e3 fixed to/fromWei a0b5353 changed outputs up to storageAt c2ed233 update balance example for new api 1f6c195 fixed toBigNumber e5cc501 updated readme 4eb857e increased meteor package version c7f8373 separated formatters files 068bdd7 changed project structure ddb90c2 refactoring formatters a6110a5 common changes d3569e4 more coverage tests e2352b4 utils.js docs 344428b tests... 9fe105e fixed from decimal; 50fc611 test for utils.toBigNumber 60ae274 code comments b8505d1 common changes ccb3775 new api method names 2b17ad6 refactoring 0a995e1 common changes in utils, fixing code complexity 3f63109 fix all failing karma tests 1fd1a31 Merge branch 'develop' into apiOverhaul 0b9d450 fixed karma test 75e92c8 Merge branch 'master' into develop a869780 Merge branch 'master' into apiOverhaul 2cdf08b Merge pull request #101 from chevdor/master 437e273 Helping travis a bit... old boy! d88effa Add node 0.12 + virtual screen for browsers/karma. 743eb30 Including Karma to Travis f0da6ef Merge remote-tracking branch 'upstream/master' cbb1efe test(eth): Disable few tests b819391 fixed tests c1136a0 Merge branch 'master' into develop 1b475aa downgrade to unreachable-branch-transform 0.1.0 636fb4b updated outdated deps cf3fa10 Merge branch 'ch' 96f3076 karma 9c72d43 Merge pull request #100 from chevdor/master 96fede8 Merge pull request #98 from kumavis/develop 833b810 doc(readme): Information about Karma in the readme e46f6f1 test(utils): Add test for the toEth() function 1e0d76e Remove phantomjs af5fef0 test(karma): Add Karma support 20c4e28 Move envify and unreachable-branch-transform to normal dependencies for external browserify support. 333c3ff merged develop b07ddb4 add defualt block 024433f Merge branch 'master' into develop 601c8ab ignore for maxcomplexity warning d9d190e Merge branch 'master' into develop a05742f Add internal defaultBlock 6cd96c9 add net object 48c107e update meteor package 9c4080b made filter polling async 869bb66 add optional callback 4096fb8 merged develop 5c4a36b working on adding callbacks 30111f7 Merge pull request #87 from kumavis/develop f2029b4 Merge pull request #85 from ethers/abiString ee686b0 Move browserify transforms to package.json 4b9bc17 constants should be before (dynamic) string contents 1c136e3 merged develop aef0171 add shh topic auto transformation for filter options 37e6d11 add shh output formatters and test c03a949 add package-init.js a69c04d add version file 487e0ac mdae it a meteor package 8cf8b9e gulp fd85749 Merge pull request #81 from ethers/arraySupport fcab219 vary the length of the arrays f8db634 need to save/concat per iteration ce664d6 fix test descriptions 66196ee constants should be before array contents, fixes #30 2cd4f02 add build files 47412c3 add more tests for blocks 545de25 add more tests 2e9a411 Merge pull request #71 from frozeman/apiOverhaul 30518ae fixed complexities 84900e6 merged with solved conflicts eaef1a2 merged develop 9981b97 fixed ) 8128342 fixed small change request 5ea5be2 add deprecated transact 181f109 changed getCode to getData 1fa7fa6 toFromWei fix ee65b2c add input formatter for transactions fec54d8 add depreaction warnring to contractFromAbi 684c495 changed contract API 36ca47f Changed watch to filter for eth and shh 7fde77d add formatter b41d7b3 Merge branch 'master' into develop 5424406 Merge pull request #69 from frozeman/apiOverhaul 1e3edbb Merge branch 'develop' of https://github.com/ethereum/ethereum.js into apiOverhaul 60cda4e fixed tests 91c015e Made to/fromWei return strings instead of numbers 85c843e Merge pull request #67 from frozeman/apiOverhaul ed7d473 Removed enumerable from methods, fixed number property ce141d8 Removed circular dependencies 188e9e5 Add toWei/fromWei and isAddress 5c994ff changed most of the function names REVERT: 7d6b35a Merge branch 'master' into cpp REVERT: ea250e6 Merge commit 'be3bfb76bef1d1f113033cd9093e03a00066d5d1' into ethereumjs_timeout REVERT: c08cea1 Improvement to AZ - confirmation disabler. Fix network crash. git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 9926e27a84fe21f3e7250e7e245977a7125ddf63
2015-03-10 16:41:32 +00:00
describe('fromWei', function () {
it('should return the correct value', function () {
assert.equal(utils.fromWei(1000000000000000000, 'wei'), '1000000000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'kwei'), '1000000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'mwei'), '1000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'gwei'), '1000000000');
assert.equal(utils.fromWei(1000000000000000000, 'szabo'), '1000000');
assert.equal(utils.fromWei(1000000000000000000, 'finney'), '1000');
assert.equal(utils.fromWei(1000000000000000000, 'ether'), '1');
assert.equal(utils.fromWei(1000000000000000000, 'kether'), '0.001');
assert.equal(utils.fromWei(1000000000000000000, 'grand'), '0.001');
assert.equal(utils.fromWei(1000000000000000000, 'mether'), '0.000001');
assert.equal(utils.fromWei(1000000000000000000, 'gether'), '0.000000001');
assert.equal(utils.fromWei(1000000000000000000, 'tether'), '0.000000000001');
});
});
});