|
|
@ -1,5 +1,5 @@ |
|
|
|
|
|
|
|
|
|
|
|
const assertRevert = require('./helpers/assertRevert'); |
|
|
|
import assertRevert from './helpers/assertRevert'; |
|
|
|
|
|
|
|
|
|
|
|
var StandardTokenMock = artifacts.require('mocks/StandardTokenMock.sol'); |
|
|
|
var StandardTokenMock = artifacts.require('mocks/StandardTokenMock.sol'); |
|
|
|
|
|
|
|
|
|
|
@ -36,12 +36,7 @@ contract('StandardToken', function (accounts) { |
|
|
|
|
|
|
|
|
|
|
|
it('should throw an error when trying to transfer more than balance', async function () { |
|
|
|
it('should throw an error when trying to transfer more than balance', async function () { |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
try { |
|
|
|
await assertRevert(token.transfer(accounts[1], 101)); |
|
|
|
await token.transfer(accounts[1], 101); |
|
|
|
|
|
|
|
assert.fail('should have thrown before'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
assertRevert(error); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should return correct balances after transfering from another account', async function () { |
|
|
|
it('should return correct balances after transfering from another account', async function () { |
|
|
@ -61,23 +56,13 @@ contract('StandardToken', function (accounts) { |
|
|
|
|
|
|
|
|
|
|
|
it('should throw an error when trying to transfer more than allowed', async function () { |
|
|
|
it('should throw an error when trying to transfer more than allowed', async function () { |
|
|
|
await token.approve(accounts[1], 99); |
|
|
|
await token.approve(accounts[1], 99); |
|
|
|
try { |
|
|
|
await assertRevert(token.transferFrom(accounts[0], accounts[2], 100, { from: accounts[1] })); |
|
|
|
await token.transferFrom(accounts[0], accounts[2], 100, { from: accounts[1] }); |
|
|
|
|
|
|
|
assert.fail('should have thrown before'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
assertRevert(error); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should throw an error when trying to transferFrom more than _from has', async function () { |
|
|
|
it('should throw an error when trying to transferFrom more than _from has', async function () { |
|
|
|
let balance0 = await token.balanceOf(accounts[0]); |
|
|
|
let balance0 = await token.balanceOf(accounts[0]); |
|
|
|
await token.approve(accounts[1], 99); |
|
|
|
await token.approve(accounts[1], 99); |
|
|
|
try { |
|
|
|
await assertRevert(token.transferFrom(accounts[0], accounts[2], balance0 + 1, { from: accounts[1] })); |
|
|
|
await token.transferFrom(accounts[0], accounts[2], balance0 + 1, { from: accounts[1] }); |
|
|
|
|
|
|
|
assert.fail('should have thrown before'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
assertRevert(error); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('validating allowance updates to spender', function () { |
|
|
|
describe('validating allowance updates to spender', function () { |
|
|
@ -107,22 +92,12 @@ contract('StandardToken', function (accounts) { |
|
|
|
|
|
|
|
|
|
|
|
it('should throw an error when trying to transfer to 0x0', async function () { |
|
|
|
it('should throw an error when trying to transfer to 0x0', async function () { |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
try { |
|
|
|
await assertRevert(token.transfer(0x0, 100)); |
|
|
|
await token.transfer(0x0, 100); |
|
|
|
|
|
|
|
assert.fail('should have thrown before'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
assertRevert(error); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should throw an error when trying to transferFrom to 0x0', async function () { |
|
|
|
it('should throw an error when trying to transferFrom to 0x0', async function () { |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
let token = await StandardTokenMock.new(accounts[0], 100); |
|
|
|
await token.approve(accounts[1], 100); |
|
|
|
await token.approve(accounts[1], 100); |
|
|
|
try { |
|
|
|
await assertRevert(token.transferFrom(accounts[0], 0x0, 100, { from: accounts[1] })); |
|
|
|
await token.transferFrom(accounts[0], 0x0, 100, { from: accounts[1] }); |
|
|
|
|
|
|
|
assert.fail('should have thrown before'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
assertRevert(error); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|