篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript [JS] Promise VS Async / Await相关的知识,希望对你有一定的参考价值。
it("it should be possible to put money inside", function() {
var contractInstance;
myWallet.deployed().then(function(instance) {
contractInstance = instance;
return contractInstance.sendTransaction({
from: accounts[0],
address: contractInstance.address,
value: web3.toWei(10, 'ether')
});
}).then(function(tx) {
assert.equal(
web3.eth.getBalance(contractInstance.address).toNumber(),
web3.toWei(10, 'ether'),
'The balance is same'
);
});
});
it("it should be possible to put money inside", async function() {
var contract = await myWallet.deployed();
var tx = await contract.sendTransaction({
from: accounts[0],
address: contract.address,
value: web3.toWei(10, 'ether')
});
assert.equal(
web3.eth.getBalance(contract.address).toNumber(),
web3.toWei(10, 'ether'),
'The balance is same'
);
});
以上是关于javascript [JS] Promise VS Async / Await的主要内容,如果未能解决你的问题,请参考以下文章