From 93a5b3f457c1211676296840c285759007a55500 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 30 Jan 2018 13:21:01 +0100 Subject: Fix prettier --- .../contracts/test/ts/multi_sig_with_time_lock.ts | 178 ++++++++++----------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'packages/contracts/test/ts/multi_sig_with_time_lock.ts') diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts index ea939a758..fa2028437 100644 --- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts @@ -23,93 +23,93 @@ const expect = chai.expect; const web3: Web3 = (global as any).web3; contract('MultiSigWalletWithTimeLock', (accounts: string[]) => { - const owners = [accounts[0], accounts[1]]; - const SECONDS_TIME_LOCKED = 10000; - - let multiSig: ContractInstance; - let multiSigWrapper: MultiSigWrapper; - let txId: number; - let initialSecondsTimeLocked: number; - let rpc: RPC; - - before(async () => { - multiSig = await MultiSigWalletWithTimeLock.deployed(); - multiSigWrapper = new MultiSigWrapper(multiSig); - - const secondsTimeLocked = await multiSig.secondsTimeLocked.call(); - initialSecondsTimeLocked = secondsTimeLocked.toNumber(); - const rpcUrl = `http://${truffleConf.networks.development.host}:${truffleConf.networks.development.port}`; - rpc = new RPC(rpcUrl); - }); - - describe('changeTimeLock', () => { - it('should throw when not called by wallet', async () => { - return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, { from: owners[0] })).to.be.rejectedWith( - constants.REVERT, - ); - }); - - it('should throw without enough confirmations', async () => { - const destination = multiSig.address; - const from = owners[0]; - const dataParams = { - name: 'changeTimeLock', - abi: MULTI_SIG_ABI, - args: [SECONDS_TIME_LOCKED], - }; - const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams); - - txId = subRes.logs[0].args.transactionId.toNumber(); - return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT); - }); - - it('should set confirmation time with enough confirmations', async () => { - const res = await multiSig.confirmTransaction(txId, { from: owners[1] }); - expect(res.logs).to.have.length(2); - const blockNum = await promisify(web3.eth.getBlockNumber)(); - const blockInfo = await promisify(web3.eth.getBlock)(blockNum); - const timestamp = new BigNumber(blockInfo.timestamp); - const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.call(txId)); - - expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); - }); - - it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { - expect(initialSecondsTimeLocked).to.be.equal(0); - - const res = await multiSig.executeTransaction(txId); - expect(res.logs).to.have.length(2); - - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.call()); - expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); - }); - - const newSecondsTimeLocked = 0; - it('should throw if it has enough confirmations but is not past the time lock', async () => { - const destination = multiSig.address; - const from = owners[0]; - const dataParams = { - name: 'changeTimeLock', - abi: MULTI_SIG_ABI, - args: [newSecondsTimeLocked], - }; - const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams); - - txId = subRes.logs[0].args.transactionId.toNumber(); - const confRes = await multiSig.confirmTransaction(txId, { - from: owners[1], - }); - expect(confRes.logs).to.have.length(2); - - return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT); - }); - - it('should execute if it has enough confirmations and is past the time lock', async () => { - await rpc.increaseTimeAsync(SECONDS_TIME_LOCKED); - await multiSig.executeTransaction(txId); - - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.call()); - expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); - }); - }); + const owners = [accounts[0], accounts[1]]; + const SECONDS_TIME_LOCKED = 10000; + + let multiSig: ContractInstance; + let multiSigWrapper: MultiSigWrapper; + let txId: number; + let initialSecondsTimeLocked: number; + let rpc: RPC; + + before(async () => { + multiSig = await MultiSigWalletWithTimeLock.deployed(); + multiSigWrapper = new MultiSigWrapper(multiSig); + + const secondsTimeLocked = await multiSig.secondsTimeLocked.call(); + initialSecondsTimeLocked = secondsTimeLocked.toNumber(); + const rpcUrl = `http://${truffleConf.networks.development.host}:${truffleConf.networks.development.port}`; + rpc = new RPC(rpcUrl); + }); + + describe('changeTimeLock', () => { + it('should throw when not called by wallet', async () => { + return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, { from: owners[0] })).to.be.rejectedWith( + constants.REVERT, + ); + }); + + it('should throw without enough confirmations', async () => { + const destination = multiSig.address; + const from = owners[0]; + const dataParams = { + name: 'changeTimeLock', + abi: MULTI_SIG_ABI, + args: [SECONDS_TIME_LOCKED], + }; + const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams); + + txId = subRes.logs[0].args.transactionId.toNumber(); + return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT); + }); + + it('should set confirmation time with enough confirmations', async () => { + const res = await multiSig.confirmTransaction(txId, { from: owners[1] }); + expect(res.logs).to.have.length(2); + const blockNum = await promisify(web3.eth.getBlockNumber)(); + const blockInfo = await promisify(web3.eth.getBlock)(blockNum); + const timestamp = new BigNumber(blockInfo.timestamp); + const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.call(txId)); + + expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); + }); + + it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { + expect(initialSecondsTimeLocked).to.be.equal(0); + + const res = await multiSig.executeTransaction(txId); + expect(res.logs).to.have.length(2); + + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.call()); + expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); + }); + + const newSecondsTimeLocked = 0; + it('should throw if it has enough confirmations but is not past the time lock', async () => { + const destination = multiSig.address; + const from = owners[0]; + const dataParams = { + name: 'changeTimeLock', + abi: MULTI_SIG_ABI, + args: [newSecondsTimeLocked], + }; + const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams); + + txId = subRes.logs[0].args.transactionId.toNumber(); + const confRes = await multiSig.confirmTransaction(txId, { + from: owners[1], + }); + expect(confRes.logs).to.have.length(2); + + return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT); + }); + + it('should execute if it has enough confirmations and is past the time lock', async () => { + await rpc.increaseTimeAsync(SECONDS_TIME_LOCKED); + await multiSig.executeTransaction(txId); + + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.call()); + expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); + }); + }); }); -- cgit v1.2.3