Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test on TokenVesting draft #2350

Closed
hems opened this issue Sep 8, 2020 · 2 comments
Closed

Fix test on TokenVesting draft #2350

hems opened this issue Sep 8, 2020 · 2 comments

Comments

@hems
Copy link

hems commented Sep 8, 2020

I just went through the tests on TokenVesting and figured out that this test isn't finished:

it('should keep the vested tokens when revoked by owner', async function () {
await time.increaseTo(this.start.add(this.cliffDuration).add(time.duration.weeks(12)));
const vestedPre = vestedAmount(amount, await time.latest(), this.start, this.cliffDuration, this.duration);
await this.vesting.revoke(this.token.address, { from: owner });
const vestedPost = vestedAmount(amount, await time.latest(), this.start, this.cliffDuration, this.duration);
expect(vestedPre).to.be.bignumber.equal(vestedPost);
});

What actually needs to be done in order for this test to be valuable is:

  1. Add the "vested()" method on TokenVesting.sol
    /**
     * @return the vested amount of the token vesting.
     */
    function vested(IERC20 token) public view returns (uint256) {
        return _vestedAmount(token);
    }
  1. Call the vested() method on the test instead of using the vestedAmount function from the test file
    expect(await this.vesting.vested()).to.equal(vestedPre);

Other than all the tests seems to be perfect, thanks a lot for all your work

@abcoathup
Copy link
Contributor

Hi @hems,

Thanks for the feedback. The drafts directory was removed from OpenZeppelin Contracts 3.0.
See the documentation for details: https://docs.openzeppelin.com/contracts/3.x/drafts

If you look at #1214 TokenVesting may not be aligned with traditional vesting.

Depending on your use case, you could use TokenTimelock

When creating token time locks or vesting you should consider prevention strategies for: Bypassing Smart Contract Timelocks

I will close this issue as TokenVesting has been removed but really appreciate the feedback on the test.

@hems
Copy link
Author

hems commented Sep 8, 2020

Hi @hems,

Hello

Thanks for the feedback. The drafts directory was removed from OpenZeppelin Contracts 3.0.
See the documentation for details: https://docs.openzeppelin.com/contracts/3.x/drafts

Yes I noticed!

If you look at #1214 TokenVesting may not be aligned with traditional vesting.

Actually the linear vesting is the perfect implementation for me and to be frank, I believe to a lot more people, making it more "feature-rich" ( aka complicated ) seems to create a lot of room for discussion and bugs, so in a way I really think the linear lock it the perfect solution as it's very simple to understand and to test, by tweaking that test i posted here i was able to get 100% test coverage.

Depending on your use case, you could use TokenTimelock

Thanks for the link, I'll use the TokenVesting contract tough as it works just as we would like it to work.

When creating token time locks or vesting you should consider prevention strategies for: Bypassing Smart Contract Timelocks

very interesting concept, thank you for pointing me out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants