|
1 | 1 | const helpers = require('./helpers');
|
2 | 2 |
|
3 | 3 | const Wallet = artifacts.require("./Wallet.sol");
|
4 |
| -const DxDAOTimeLock = artifacts.require("./DxDAOTimeLock.sol"); |
5 |
| -contract('DxDAOTimeLock', accounts => { |
| 4 | +const TimeLock = artifacts.require("./TimeLock.sol"); |
| 5 | +contract('TimeLock', accounts => { |
6 | 6 |
|
7 | 7 | it("sendEther", async () => {
|
8 | 8 | var wallet = await Wallet.new();
|
9 | 9 | await wallet.initialize(accounts[0]);
|
10 | 10 | var owner = wallet.address;
|
11 | 11 | var block = await web3.eth.getBlock("latest");
|
12 | 12 | var releaseTime = block.timestamp + (30*60*60*24);
|
13 |
| - var dxDAOTimeLock = await DxDAOTimeLock.new(owner,releaseTime); |
14 |
| - assert.equal(await dxDAOTimeLock.owner(), owner); |
15 |
| - assert.equal(await dxDAOTimeLock.releaseTime(), releaseTime); |
| 13 | + var timeLock = await TimeLock.new(owner,releaseTime); |
| 14 | + assert.equal(await timeLock.owner(), owner); |
| 15 | + assert.equal(await timeLock.releaseTime(), releaseTime); |
16 | 16 |
|
17 | 17 | //send funds to wallet
|
18 | 18 | await web3.eth.sendTransaction({from:accounts[0],to:owner, value: web3.utils.toWei('10', "ether")});
|
19 | 19 | assert.equal(await web3.eth.getBalance(owner), web3.utils.toWei('10', "ether"));
|
20 |
| - await wallet.pay(dxDAOTimeLock.address); |
21 |
| - await wallet.pay(dxDAOTimeLock.address); |
22 |
| - assert.equal(await web3.eth.getBalance(dxDAOTimeLock.address), web3.utils.toWei('10', "ether")); |
| 20 | + await wallet.pay(timeLock.address); |
| 21 | + await wallet.pay(timeLock.address); |
| 22 | + assert.equal(await web3.eth.getBalance(timeLock.address), web3.utils.toWei('10', "ether")); |
23 | 23 |
|
24 |
| - var encodedABI = await new web3.eth.Contract(dxDAOTimeLock.abi) |
| 24 | + var encodedABI = await new web3.eth.Contract(timeLock.abi) |
25 | 25 | .methods
|
26 | 26 | .withdraw()
|
27 | 27 | .encodeABI();
|
28 | 28 |
|
29 | 29 | try {
|
30 |
| - await wallet.genericCall(dxDAOTimeLock.address, encodedABI); |
| 30 | + await wallet.genericCall(timeLock.address, encodedABI); |
31 | 31 | throw 'cannot withdraw before time';
|
32 | 32 | } catch (error) {
|
33 | 33 | helpers.assertVMException(error);
|
34 | 34 | }
|
35 | 35 | await helpers.increaseTime((30*60*60*24)+1);
|
36 | 36 | try {
|
37 |
| - await dxDAOTimeLock.withdraw(); |
| 37 | + await timeLock.withdraw(); |
38 | 38 | throw 'only Owner can withdraw';
|
39 | 39 | } catch (error) {
|
40 | 40 | helpers.assertVMException(error);
|
41 | 41 | }
|
42 |
| - await wallet.genericCall(dxDAOTimeLock.address, encodedABI); |
| 42 | + await wallet.genericCall(timeLock.address, encodedABI); |
43 | 43 | assert.equal(await web3.eth.getBalance(owner), web3.utils.toWei('10', "ether"));
|
44 | 44 | });
|
45 | 45 | });
|
0 commit comments