|
| 1 | +const utils = require('./utils/general') |
| 2 | + |
| 3 | +const GnosisSafe = artifacts.require("./GnosisSafe.sol") |
| 4 | + |
| 5 | +contract('GnosisSafe setup', function(accounts) { |
| 6 | + |
| 7 | + let gnosisSafe |
| 8 | + let executor = accounts[8] |
| 9 | + |
| 10 | + const CALL = 0 |
| 11 | + |
| 12 | + it.only('should not be able to call execTransaction before setup', async () => { |
| 13 | + |
| 14 | + // Create lightwallet |
| 15 | + gnosisSafe = await utils.deployContract("deploying Gnosis Safe", GnosisSafe) |
| 16 | + |
| 17 | + // Fund Safe |
| 18 | + await web3.eth.sendTransaction({from: accounts[0], to: gnosisSafe.address, value: web3.toWei(1, 'ether')}) |
| 19 | + assert.equal(await web3.eth.getBalance(gnosisSafe.address).toNumber(), web3.toWei(1, 'ether')) |
| 20 | + |
| 21 | + let sigs = "0x000000000000000000000000" + executor.replace('0x', '') + "0000000000000000000000000000000000000000000000000000000000000000" + "01" |
| 22 | + |
| 23 | + await utils.assertRejects( |
| 24 | + gnosisSafe.execTransaction( |
| 25 | + accounts[0], web3.toWei(1, 'ether'), "0x", CALL, 0, 0, 0, 0, 0, sigs, {from: executor} |
| 26 | + ), |
| 27 | + "Should not be able to execute transaction before setup" |
| 28 | + ) |
| 29 | + |
| 30 | + assert.equal(await web3.eth.getBalance(gnosisSafe.address).toNumber(), web3.toWei(1, 'ether')) |
| 31 | + |
| 32 | + let setup = await gnosisSafe.setup([executor], 1, 0, "0x", 0, 0, 0, 0) |
| 33 | + utils.logGasUsage("setup", setup) |
| 34 | + |
| 35 | + assert.equal(await web3.eth.getBalance(gnosisSafe.address).toNumber(), web3.toWei(1, 'ether')) |
| 36 | + |
| 37 | + let tx = await gnosisSafe.execTransaction( |
| 38 | + executor, web3.toWei(1, 'ether'), "0x", CALL, 0, 0, 0, 0, 0, sigs, {from: executor} |
| 39 | + ) |
| 40 | + utils.logGasUsage("execTransaction after setup", tx) |
| 41 | + |
| 42 | + assert.equal(await web3.eth.getBalance(gnosisSafe.address).toNumber(), web3.toWei(0, 'ether')) |
| 43 | + |
| 44 | + }) |
| 45 | +}) |
0 commit comments