-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability for users to convert timelock back into deposit (#71)
- Loading branch information
1 parent
41bd925
commit 3fddcc1
Showing
5 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { PoolEnv } = require('./support/PoolEnv') | ||
|
||
describe('Re-deposit Timelocked Tokens', () => { | ||
|
||
let env | ||
|
||
beforeEach(() => { | ||
env = new PoolEnv() | ||
}) | ||
|
||
describe('convert timelock to tickets', () => { | ||
it('should allow the user to re-deposit timelock as tickets', async () => { | ||
await env.createPool({ prizePeriodSeconds: 10, exitFee: '0.1', creditRate: '0.01' }) | ||
// buy at time zero so that it is considered a 'full' ticket | ||
await env.buyTicketsAtTime({ user: 1, tickets: 100, elapsed: 0 }) | ||
await env.withdrawWithTimelockAtTime({ user: 1, tickets: 100, elapsed: 0 }) | ||
|
||
// tickets are converted to timelock | ||
await env.expectUserToHaveTimelock({ user: 1, timelock: 100 }) | ||
await env.expectUserTimelockAvailableAt({ user: 1, elapsed: 10 }) | ||
|
||
await env.timelockBuyTickets({ user: 1, tickets: 100 }) | ||
|
||
// expect balance | ||
await env.expectUserToHaveTickets({ user: 1, tickets: 100 }) | ||
await env.expectUserToHaveTimelock({ user: 1, timelock: 0 }) | ||
}) | ||
}) | ||
|
||
describe('convert timelock to sponsorship', () => { | ||
it('should allow the user to re-deposit timelock as tickets', async () => { | ||
await env.createPool({ prizePeriodSeconds: 10, exitFee: '0.1', creditRate: '0.01' }) | ||
// buy at time zero so that it is considered a 'full' ticket | ||
await env.buyTicketsAtTime({ user: 1, tickets: 100, elapsed: 0 }) | ||
await env.withdrawWithTimelockAtTime({ user: 1, tickets: 100, elapsed: 0 }) | ||
|
||
// tickets are converted to timelock | ||
await env.expectUserToHaveTimelock({ user: 1, timelock: 100 }) | ||
await env.expectUserTimelockAvailableAt({ user: 1, elapsed: 10 }) | ||
|
||
await env.timelockBuySponsorship({ user: 1, sponsorship: 100 }) | ||
|
||
// expect balance | ||
await env.expectUserToHaveSponsorship({ user: 1, sponsorship: 100 }) | ||
await env.expectUserToHaveTimelock({ user: 1, timelock: 0 }) | ||
}) | ||
}) | ||
}) |