protocol/contracts/staking/test/epoch_test.ts
Xianny f0d7d10fe7
update abi-gen with new method interfaces (#2325)
* update abi-gen with new method interfaces

* wip: get all packages to build

* wip: get all packages to build

* Fix two contract wrapper calls

* Export necessary types part of the contract wrapper public interfaces

* Revive and fix wrapper_unit_tests

* Remove duplicate type

* Fix lib_exchange_rich_error_decoder tests

* Fix remaining test failures in contracts-* packages

* Prettier fixes

* remove transactionHelper

* lint and update changelogs

* Fix prettier

* Revert changes to reference docs

* Add back changelog already published and add revert changelog entry

* Add missing CHANGELOG entries

* Add missing comma

* Update mesh-rpc-client dep

* Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta

* Align package versions
2019-11-14 11:22:29 -05:00

50 lines
2.1 KiB
TypeScript

import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
import { blockchainTests, expect } from '@0x/contracts-test-utils';
import * as _ from 'lodash';
import { constants as stakingConstants } from '../src/constants';
import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper';
// tslint:disable:no-unnecessary-type-assertion
blockchainTests('Epochs', env => {
// tokens & addresses
let accounts: string[];
let owner: string;
// wrappers
let stakingApiWrapper: StakingApiWrapper;
let erc20Wrapper: ERC20Wrapper;
// tests
before(async () => {
// create accounts
accounts = await env.getAccountAddressesAsync();
owner = accounts[0];
// set up ERC20Wrapper
erc20Wrapper = new ERC20Wrapper(env.provider, accounts, owner);
// deploy staking contracts
stakingApiWrapper = await deployAndConfigureContractsAsync(env, owner, erc20Wrapper);
});
describe('Epochs & TimeLocks', () => {
it('basic epochs & timeLock periods', async () => {
///// 1/3 Validate Assumptions /////
expect((await stakingApiWrapper.utils.getParamsAsync()).epochDurationInSeconds).to.be.bignumber.equal(
stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds,
);
///// 2/3 Validate Initial Epoch & TimeLock Period /////
{
// epoch
const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync();
expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH);
}
///// 3/3 Increment Epoch (TimeLock Should Not Increment) /////
await stakingApiWrapper.utils.skipToNextEpochAndFinalizeAsync();
{
// epoch
const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch().callAsync();
expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH.plus(1));
}
});
});
});
// tslint:enable:no-unnecessary-type-assertion