|
@@ -1,4 +1,4 @@
|
|
|
-const { expectThrow } = require('../utils');
|
|
|
+import assertRevert from '../helpers/assertRevert';
|
|
|
|
|
|
const EIP20Abstraction = artifacts.require('EIP20');
|
|
|
let HST;
|
|
@@ -38,15 +38,15 @@ contract('EIP20', (accounts) => {
|
|
|
const balanceBefore = await HST.balanceOf.call(accounts[0]);
|
|
|
assert.strictEqual(balanceBefore.toNumber(), 10000);
|
|
|
|
|
|
- web3.eth.sendTransaction({ from: accounts[0], to: HST.address, value: web3.toWei('10', 'Ether') }, async (err, res) => {
|
|
|
- expectThrow(new Promise((resolve, reject) => {
|
|
|
- if (err) reject(err);
|
|
|
+ await assertRevert(new Promise((resolve, reject) => {
|
|
|
+ web3.eth.sendTransaction({ from: accounts[0], to: HST.address, value: web3.toWei('10', 'Ether') }, (err, res) => {
|
|
|
+ if (err) { reject(err); }
|
|
|
resolve(res);
|
|
|
- }));
|
|
|
+ });
|
|
|
+ }));
|
|
|
|
|
|
- const balanceAfter = await HST.balanceOf.call(accounts[0]);
|
|
|
- assert.strictEqual(balanceAfter.toNumber(), 10000);
|
|
|
- });
|
|
|
+ const balanceAfter = await HST.balanceOf.call(accounts[0]);
|
|
|
+ assert.strictEqual(balanceAfter.toNumber(), 10000);
|
|
|
});
|
|
|
|
|
|
it('transfers: should transfer 10000 to accounts[1] with accounts[0] having 10000', async () => {
|
|
@@ -55,7 +55,9 @@ contract('EIP20', (accounts) => {
|
|
|
assert.strictEqual(balance.toNumber(), 10000);
|
|
|
});
|
|
|
|
|
|
- it('transfers: should fail when trying to transfer 10001 to accounts[1] with accounts[0] having 10000', () => expectThrow(HST.transfer.call(accounts[1], 10001, { from: accounts[0] })));
|
|
|
+ it('transfers: should fail when trying to transfer 10001 to accounts[1] with accounts[0] having 10000', async () => {
|
|
|
+ await assertRevert(HST.transfer.call(accounts[1], 10001, { from: accounts[0] }));
|
|
|
+ });
|
|
|
|
|
|
it('transfers: should handle zero-transfers normally', async () => {
|
|
|
assert(await HST.transfer.call(accounts[1], 0, { from: accounts[0] }), 'zero-transfer has failed');
|
|
@@ -140,16 +142,18 @@ contract('EIP20', (accounts) => {
|
|
|
|
|
|
// FIRST tx done.
|
|
|
// onto next.
|
|
|
- expectThrow(HST.transferFrom.call(accounts[0], accounts[2], 60, { from: accounts[1] }));
|
|
|
+ await assertRevert(HST.transferFrom.call(accounts[0], accounts[2], 60, { from: accounts[1] }));
|
|
|
});
|
|
|
|
|
|
- it('approvals: attempt withdrawal from account with no allowance (should fail)', () => expectThrow(HST.transferFrom.call(accounts[0], accounts[2], 60, { from: accounts[1] })));
|
|
|
+ it('approvals: attempt withdrawal from account with no allowance (should fail)', async () => {
|
|
|
+ await assertRevert(HST.transferFrom.call(accounts[0], accounts[2], 60, { from: accounts[1] }));
|
|
|
+ });
|
|
|
|
|
|
it('approvals: allow accounts[1] 100 to withdraw from accounts[0]. Withdraw 60 and then approve 0 & attempt transfer.', async () => {
|
|
|
await HST.approve(accounts[1], 100, { from: accounts[0] });
|
|
|
await HST.transferFrom(accounts[0], accounts[2], 60, { from: accounts[1] });
|
|
|
await HST.approve(accounts[1], 0, { from: accounts[0] });
|
|
|
- expectThrow(HST.transferFrom.call(accounts[0], accounts[2], 10, { from: accounts[1] }));
|
|
|
+ await assertRevert(HST.transferFrom.call(accounts[0], accounts[2], 10, { from: accounts[1] }));
|
|
|
});
|
|
|
|
|
|
it('approvals: approve max (2^256 - 1)', async () => {
|