zulhfreelancer
11/13/2017 - 6:51 AM

[JS] Promise VS Async/Await

[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'
    );
});