2019-08-21 13:04:10 -07:00

84 lines
2.9 KiB
TypeScript

import {
chaiSetup,
constants,
expectTransactionFailedAsync,
provider,
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { RevertReason } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import {
artifacts,
StakingContract,
ZrxVaultContract
} from '../src';
import { StakingWrapper } from './utils/staking_wrapper';
import { ERC20Wrapper, ERC20ProxyContract } from '@0x/contracts-asset-proxy';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
// tslint:disable:no-unnecessary-type-assertion
describe('Staking Core', () => {
// constants
const ZRX_TOKEN_DECIMALS = new BigNumber(18);
// tokens & addresses
let owner: string;
let stakers: string[];
let makers: string[];
let delegators: string[];
let zrxTokenContract: DummyERC20TokenContract;
let erc20ProxyContract: ERC20ProxyContract;
// wrappers
let stakingWrapper: StakingWrapper;
let erc20Wrapper: ERC20Wrapper;
// tests
before(async () => {
await blockchainLifecycle.startAsync();
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
before(async () => {
// create accounts
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
stakers = accounts.slice(1);
// deploy erc20 proxy
erc20Wrapper = new ERC20Wrapper(provider, stakers, owner);
erc20ProxyContract = await erc20Wrapper.deployProxyAsync();
// deploy zrx token
[zrxTokenContract] = await erc20Wrapper.deployDummyTokensAsync(1, ZRX_TOKEN_DECIMALS);
await erc20Wrapper.setBalancesAndAllowancesAsync();
// deploy staking contracts
stakingWrapper = new StakingWrapper(provider, owner, erc20ProxyContract, zrxTokenContract.address);
await stakingWrapper.deployAndConfigureContracts();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('end-to-end tests', () => {
it.skip('staking', async () => {
const stakeAmount = stakingWrapper.toBaseUnitAmount(10);
//await stakingWrapper.stake(stakers[0], stakeAmount);
//const stakeBalance = stakingWrapper.getStakeBalance(stakers[0]);
//expect(stakeBalance).to.be.equal(stakeAmount);
const vaultBalance = stakingWrapper.getZrxVaultBalance(stakers[0]);
expect(vaultBalance).to.be.equal(stakeAmount);
});
});
});
// tslint:enable:no-unnecessary-type-assertion