You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.3 KiB
33 lines
1.3 KiB
|
|
import expectThrow from './helpers/expectThrow';
|
|
|
|
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
|
|
|
|
contract('SimpleSavingsWallet', function (accounts) {
|
|
let savingsWallet;
|
|
let owner;
|
|
|
|
const paymentAmount = 4242;
|
|
|
|
beforeEach(async function () {
|
|
savingsWallet = await SimpleSavingsWallet.new(4141);
|
|
owner = await savingsWallet.owner();
|
|
});
|
|
|
|
it('should receive funds', async function () {
|
|
await web3.eth.sendTransaction({ from: owner, to: savingsWallet.address, value: paymentAmount });
|
|
assert.isTrue((new web3.BigNumber(paymentAmount)).equals(web3.eth.getBalance(savingsWallet.address)));
|
|
});
|
|
|
|
it('owner can send funds', async function () {
|
|
// Receive payment so we have some money to spend.
|
|
await web3.eth.sendTransaction({ from: accounts[9], to: savingsWallet.address, value: 1000000 });
|
|
await expectThrow(savingsWallet.sendTo(0, paymentAmount, { from: owner }));
|
|
await expectThrow(savingsWallet.sendTo(savingsWallet.address, paymentAmount, { from: owner }));
|
|
await expectThrow(savingsWallet.sendTo(accounts[1], 0, { from: owner }));
|
|
|
|
const balance = web3.eth.getBalance(accounts[1]);
|
|
await savingsWallet.sendTo(accounts[1], paymentAmount, { from: owner });
|
|
assert.isTrue(balance.plus(paymentAmount).equals(web3.eth.getBalance(accounts[1])));
|
|
});
|
|
});
|
|
|