forked from radek1st/time-locked-wallets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeLockedWalletFactoryTest.js
39 lines (30 loc) · 1.32 KB
/
TimeLockedWalletFactoryTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const TimeLockedWallet = artifacts.require("./TimeLockedWallet.sol");
const TimeLockedWalletFactory = artifacts.require("./TimeLockedWalletFactory.sol");
let ethToSend = web3.toWei(1, "ether");
let someGas = web3.toWei(0.01, "ether");
let timeLockedWalletFactory;
let creator;
let owner;
let timeLockedWalletAbi;
contract('TimeLockedWalletFactory', (accounts) => {
before(async () => {
creator = accounts[0];
owner = accounts[1];
timeLockedWalletFactory = await TimeLockedWalletFactory.new({from: creator});
});
it("Factory created contract is working well", async () => {
// Create the wallet contract.
let now = Math.floor((new Date).getTime() / 1000);
await timeLockedWalletFactory.newTimeLockedWallet(
owner, now, {from: creator, value: ethToSend}
);
// Check if wallet can be found in creator's wallets.
let creatorWallets = await timeLockedWalletFactory.getWallets.call(creator);
assert(1 == creatorWallets.length);
// Check if wallet can be found in owners's wallets.
let ownerWallets = await timeLockedWalletFactory.getWallets.call(owner);
assert(1 == ownerWallets.length);
// Check if this is the same wallet for both of them.
assert(creatorWallets[0] === ownerWallets[0]);
});
});