【发布时间】:2018-08-31 08:03:49
【问题描述】:
我正在尝试在 karma 测试中进行一些气体交易成本计算以断言最终余额,但我无法理解为什么这两个代码 sn-ps 的输出不同
变量的值依次为:
59916559960000000000 3000000000000000000 394980000000000
sn-ps 是:
let currentBalance = web3.utils.fromWei(customerBalance.toString(), 'ether')
+ web3.utils.fromWei(customerRefundableEther.toString(), 'ether')
- web3.utils.fromWei(transactionFee.toString(), 'ether');
let currentBalance = (customerBalance / 1e18)
+(customerRefundableEther / 1e18)
- (transactionFee / 1e18);
第二个sn-p是用户账户的正确余额,断言成功。不是从wei到ether的转换:value / 1e18?。我不明白为什么,但这个 sn-ps 之间的差异超过 3 个以太单位。
我正在使用 web3 版本 1.0.0-beta26。
提前谢谢你。
【问题讨论】:
标签: javascript ethereum karma-mocha web3js web3