|
6 | 6 | } from '../../../helpers/utils.js'
|
7 | 7 | import { expectEvent, expectRevert, BN } from '@openzeppelin/test-helpers'
|
8 | 8 | import { wallets, walletAmounts, freshDeploy, approveAndStake } from '../deployment'
|
| 9 | +import { assert } from 'chai' |
9 | 10 |
|
10 | 11 | module.exports = function(accounts) {
|
11 | 12 | let owner = accounts[0]
|
@@ -317,6 +318,48 @@ module.exports = function(accounts) {
|
317 | 318 | })
|
318 | 319 |
|
319 | 320 | describe('unstake', function() {
|
| 321 | + describe('when Alice unstakes and update the signer', function() { |
| 322 | + const AliceWallet = wallets[1] |
| 323 | + const BobWallet = wallets[3] |
| 324 | + const AliceNewWallet = wallets[2] |
| 325 | + |
| 326 | + before(freshDeploy) |
| 327 | + before(doStake(AliceWallet)) |
| 328 | + before(doStake(BobWallet)) |
| 329 | + before('Change signer', async function() { |
| 330 | + const signerUpdateLimit = await this.stakeManager.signerUpdateLimit() |
| 331 | + await this.stakeManager.advanceEpoch(signerUpdateLimit) |
| 332 | + |
| 333 | + this.validatorId = await this.stakeManager.getValidatorId(AliceWallet.getAddressString()) |
| 334 | + |
| 335 | + }) |
| 336 | + |
| 337 | + it('Alice should unstake', async function() { |
| 338 | + this.receipt = await this.stakeManager.unstake(this.validatorId, { |
| 339 | + from: AliceWallet.getAddressString() |
| 340 | + }) |
| 341 | + }) |
| 342 | + |
| 343 | + it('Signers list should have only Bob\'s signer', async function() { |
| 344 | + assert((await this.stakeManager.signers(0)) == BobWallet.getChecksumAddressString(), 'no Bob signer!') |
| 345 | + await expectRevert.unspecified(this.stakeManager.signers(1)) |
| 346 | + }) |
| 347 | + |
| 348 | + it('Alice should update signer', async function() { |
| 349 | + await this.stakeManager.updateSigner(this.validatorId, AliceNewWallet.getPublicKeyString(), { |
| 350 | + from: AliceWallet.getAddressString() |
| 351 | + }) |
| 352 | + }) |
| 353 | + |
| 354 | + it('Signers list should have new Alice\'s signer and Bob\'s signer', async function() { |
| 355 | + const signers = [await this.stakeManager.signers(0), await this.stakeManager.signers(1)] |
| 356 | + |
| 357 | + |
| 358 | + assert(signers.findIndex(x => x == AliceNewWallet.getChecksumAddressString()) !== -1, 'no Alice signer!') |
| 359 | + assert(signers.findIndex(x => x == BobWallet.getChecksumAddressString()) !== -1, 'no Bob signer!') |
| 360 | + }) |
| 361 | + }) |
| 362 | + |
320 | 363 | describe('when user unstakes right after stake', async function() {
|
321 | 364 | const user = wallets[2].getChecksumAddressString()
|
322 | 365 | const amounts = walletAmounts[wallets[2].getAddressString()]
|
|
0 commit comments