Move check to transferFrom and add tests

This commit is contained in:
Jorge Izquierdo
2017-03-06 11:09:01 +01:00
parent 23703280ee
commit 12aadbed51
2 changed files with 22 additions and 5 deletions

View File

@ -52,6 +52,16 @@ contract('VestedToken', function(accounts) {
assert.fail('should have thrown before');
})
it('throws when trying to transfer from non vested tokens', async () => {
try {
await token.approve(accounts[7], 1, { from: receiver })
await token.transferFrom(receiver, accounts[7], tokenAmount, { from: accounts[7] })
} catch(error) {
return assertJump(error);
}
assert.fail('should have thrown before');
})
it('can be revoked by granter', async () => {
await token.revokeTokenGrant(receiver, 0, { from: granter });
assert.equal(await token.balanceOf(receiver), 0);
@ -78,5 +88,12 @@ contract('VestedToken', function(accounts) {
await token.transfer(accounts[7], tokenAmount, { from: receiver })
assert.equal(await token.balanceOf(accounts[7]), tokenAmount);
})
it('can approve and transferFrom all tokens after vesting ends', async () => {
await timer(vesting + 1);
await token.approve(accounts[7], tokenAmount, { from: receiver })
await token.transferFrom(receiver, accounts[7], tokenAmount, { from: accounts[7] })
assert.equal(await token.balanceOf(accounts[7]), tokenAmount);
})
})
});