Remove tests related to read-only mode
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||||
"abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IZrxVault|IZrxVaultBackstop|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewards|MixinStorage|ReadOnlyProxy|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestExchangeManager|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestMixinParams|TestMixinStake|TestMixinStakeStorage|TestMixinStakingPool|TestProtocolFees|TestStaking|TestStakingNoWETH|TestStakingProxy|TestStorageLayoutAndConstants|ZrxVault|ZrxVaultBackstop).json"
|
"abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IZrxVault|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewards|MixinStorage|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestExchangeManager|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestMixinParams|TestMixinStake|TestMixinStakeStorage|TestMixinStakingPool|TestProtocolFees|TestStaking|TestStakingNoWETH|TestStakingProxy|TestStorageLayoutAndConstants|ZrxVault).json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import * as IStorage from '../generated-artifacts/IStorage.json';
|
|||||||
import * as IStorageInit from '../generated-artifacts/IStorageInit.json';
|
import * as IStorageInit from '../generated-artifacts/IStorageInit.json';
|
||||||
import * as IStructs from '../generated-artifacts/IStructs.json';
|
import * as IStructs from '../generated-artifacts/IStructs.json';
|
||||||
import * as IZrxVault from '../generated-artifacts/IZrxVault.json';
|
import * as IZrxVault from '../generated-artifacts/IZrxVault.json';
|
||||||
import * as IZrxVaultBackstop from '../generated-artifacts/IZrxVaultBackstop.json';
|
|
||||||
import * as LibCobbDouglas from '../generated-artifacts/LibCobbDouglas.json';
|
import * as LibCobbDouglas from '../generated-artifacts/LibCobbDouglas.json';
|
||||||
import * as LibFixedMath from '../generated-artifacts/LibFixedMath.json';
|
import * as LibFixedMath from '../generated-artifacts/LibFixedMath.json';
|
||||||
import * as LibFixedMathRichErrors from '../generated-artifacts/LibFixedMathRichErrors.json';
|
import * as LibFixedMathRichErrors from '../generated-artifacts/LibFixedMathRichErrors.json';
|
||||||
@@ -34,7 +33,6 @@ import * as MixinStakeStorage from '../generated-artifacts/MixinStakeStorage.jso
|
|||||||
import * as MixinStakingPool from '../generated-artifacts/MixinStakingPool.json';
|
import * as MixinStakingPool from '../generated-artifacts/MixinStakingPool.json';
|
||||||
import * as MixinStakingPoolRewards from '../generated-artifacts/MixinStakingPoolRewards.json';
|
import * as MixinStakingPoolRewards from '../generated-artifacts/MixinStakingPoolRewards.json';
|
||||||
import * as MixinStorage from '../generated-artifacts/MixinStorage.json';
|
import * as MixinStorage from '../generated-artifacts/MixinStorage.json';
|
||||||
import * as ReadOnlyProxy from '../generated-artifacts/ReadOnlyProxy.json';
|
|
||||||
import * as Staking from '../generated-artifacts/Staking.json';
|
import * as Staking from '../generated-artifacts/Staking.json';
|
||||||
import * as StakingProxy from '../generated-artifacts/StakingProxy.json';
|
import * as StakingProxy from '../generated-artifacts/StakingProxy.json';
|
||||||
import * as TestAssertStorageParams from '../generated-artifacts/TestAssertStorageParams.json';
|
import * as TestAssertStorageParams from '../generated-artifacts/TestAssertStorageParams.json';
|
||||||
@@ -58,13 +56,10 @@ import * as TestStakingNoWETH from '../generated-artifacts/TestStakingNoWETH.jso
|
|||||||
import * as TestStakingProxy from '../generated-artifacts/TestStakingProxy.json';
|
import * as TestStakingProxy from '../generated-artifacts/TestStakingProxy.json';
|
||||||
import * as TestStorageLayoutAndConstants from '../generated-artifacts/TestStorageLayoutAndConstants.json';
|
import * as TestStorageLayoutAndConstants from '../generated-artifacts/TestStorageLayoutAndConstants.json';
|
||||||
import * as ZrxVault from '../generated-artifacts/ZrxVault.json';
|
import * as ZrxVault from '../generated-artifacts/ZrxVault.json';
|
||||||
import * as ZrxVaultBackstop from '../generated-artifacts/ZrxVaultBackstop.json';
|
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
ReadOnlyProxy: ReadOnlyProxy as ContractArtifact,
|
|
||||||
Staking: Staking as ContractArtifact,
|
Staking: Staking as ContractArtifact,
|
||||||
StakingProxy: StakingProxy as ContractArtifact,
|
StakingProxy: StakingProxy as ContractArtifact,
|
||||||
ZrxVault: ZrxVault as ContractArtifact,
|
ZrxVault: ZrxVault as ContractArtifact,
|
||||||
ZrxVaultBackstop: ZrxVaultBackstop as ContractArtifact,
|
|
||||||
MixinExchangeFees: MixinExchangeFees as ContractArtifact,
|
MixinExchangeFees: MixinExchangeFees as ContractArtifact,
|
||||||
MixinExchangeManager: MixinExchangeManager as ContractArtifact,
|
MixinExchangeManager: MixinExchangeManager as ContractArtifact,
|
||||||
MixinConstants: MixinConstants as ContractArtifact,
|
MixinConstants: MixinConstants as ContractArtifact,
|
||||||
@@ -77,7 +72,6 @@ export const artifacts = {
|
|||||||
IStorageInit: IStorageInit as ContractArtifact,
|
IStorageInit: IStorageInit as ContractArtifact,
|
||||||
IStructs: IStructs as ContractArtifact,
|
IStructs: IStructs as ContractArtifact,
|
||||||
IZrxVault: IZrxVault as ContractArtifact,
|
IZrxVault: IZrxVault as ContractArtifact,
|
||||||
IZrxVaultBackstop: IZrxVaultBackstop as ContractArtifact,
|
|
||||||
LibCobbDouglas: LibCobbDouglas as ContractArtifact,
|
LibCobbDouglas: LibCobbDouglas as ContractArtifact,
|
||||||
LibFixedMath: LibFixedMath as ContractArtifact,
|
LibFixedMath: LibFixedMath as ContractArtifact,
|
||||||
LibFixedMathRichErrors: LibFixedMathRichErrors as ContractArtifact,
|
LibFixedMathRichErrors: LibFixedMathRichErrors as ContractArtifact,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export * from '../generated-wrappers/i_storage';
|
|||||||
export * from '../generated-wrappers/i_storage_init';
|
export * from '../generated-wrappers/i_storage_init';
|
||||||
export * from '../generated-wrappers/i_structs';
|
export * from '../generated-wrappers/i_structs';
|
||||||
export * from '../generated-wrappers/i_zrx_vault';
|
export * from '../generated-wrappers/i_zrx_vault';
|
||||||
export * from '../generated-wrappers/i_zrx_vault_backstop';
|
|
||||||
export * from '../generated-wrappers/lib_cobb_douglas';
|
export * from '../generated-wrappers/lib_cobb_douglas';
|
||||||
export * from '../generated-wrappers/lib_fixed_math';
|
export * from '../generated-wrappers/lib_fixed_math';
|
||||||
export * from '../generated-wrappers/lib_fixed_math_rich_errors';
|
export * from '../generated-wrappers/lib_fixed_math_rich_errors';
|
||||||
@@ -32,7 +31,6 @@ export * from '../generated-wrappers/mixin_stake_storage';
|
|||||||
export * from '../generated-wrappers/mixin_staking_pool';
|
export * from '../generated-wrappers/mixin_staking_pool';
|
||||||
export * from '../generated-wrappers/mixin_staking_pool_rewards';
|
export * from '../generated-wrappers/mixin_staking_pool_rewards';
|
||||||
export * from '../generated-wrappers/mixin_storage';
|
export * from '../generated-wrappers/mixin_storage';
|
||||||
export * from '../generated-wrappers/read_only_proxy';
|
|
||||||
export * from '../generated-wrappers/staking';
|
export * from '../generated-wrappers/staking';
|
||||||
export * from '../generated-wrappers/staking_proxy';
|
export * from '../generated-wrappers/staking_proxy';
|
||||||
export * from '../generated-wrappers/test_assert_storage_params';
|
export * from '../generated-wrappers/test_assert_storage_params';
|
||||||
@@ -56,4 +54,3 @@ export * from '../generated-wrappers/test_staking_no_w_e_t_h';
|
|||||||
export * from '../generated-wrappers/test_staking_proxy';
|
export * from '../generated-wrappers/test_staking_proxy';
|
||||||
export * from '../generated-wrappers/test_storage_layout_and_constants';
|
export * from '../generated-wrappers/test_storage_layout_and_constants';
|
||||||
export * from '../generated-wrappers/zrx_vault';
|
export * from '../generated-wrappers/zrx_vault';
|
||||||
export * from '../generated-wrappers/zrx_vault_backstop';
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
|
||||||
import { blockchainTests, describe, expect } from '@0x/contracts-test-utils';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { StakingProxyReadOnlyModeSetEventArgs } from '../src';
|
|
||||||
|
|
||||||
import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper';
|
|
||||||
import { toBaseUnitAmount } from './utils/number_utils';
|
|
||||||
import { StakeStatus } from './utils/types';
|
|
||||||
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
|
||||||
blockchainTests.resets('Catastrophe Tests', env => {
|
|
||||||
// constants
|
|
||||||
const ZERO = new BigNumber(0);
|
|
||||||
// tokens & addresses
|
|
||||||
let accounts: string[];
|
|
||||||
let owner: string;
|
|
||||||
let actors: string[];
|
|
||||||
// wrappers
|
|
||||||
let stakingApiWrapper: StakingApiWrapper;
|
|
||||||
let erc20Wrapper: ERC20Wrapper;
|
|
||||||
// tests
|
|
||||||
before(async () => {
|
|
||||||
// create accounts
|
|
||||||
accounts = await env.web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
owner = accounts[0];
|
|
||||||
actors = accounts.slice(2, 5);
|
|
||||||
// set up ERC20Wrapper
|
|
||||||
erc20Wrapper = new ERC20Wrapper(env.provider, accounts, owner);
|
|
||||||
// deploy staking contracts
|
|
||||||
stakingApiWrapper = await deployAndConfigureContractsAsync(env, owner, erc20Wrapper);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Read-Only Mode', () => {
|
|
||||||
it('should be able to change state by default', async () => {
|
|
||||||
// stake some zrx and assert the balance
|
|
||||||
const amountToStake = toBaseUnitAmount(10);
|
|
||||||
await stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amountToStake, {
|
|
||||||
from: actors[0],
|
|
||||||
});
|
|
||||||
const undelegatedStakeBalance = await stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync(
|
|
||||||
actors[0],
|
|
||||||
StakeStatus.Undelegated,
|
|
||||||
);
|
|
||||||
expect(undelegatedStakeBalance.currentEpochBalance).to.be.bignumber.equal(amountToStake);
|
|
||||||
});
|
|
||||||
it('should not change state when in read-only mode', async () => {
|
|
||||||
// set to read-only mode
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(true);
|
|
||||||
// try to stake
|
|
||||||
const amountToStake = toBaseUnitAmount(10);
|
|
||||||
await stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amountToStake, {
|
|
||||||
from: actors[0],
|
|
||||||
});
|
|
||||||
const undelegatedStakeBalance = await stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync(
|
|
||||||
actors[0],
|
|
||||||
StakeStatus.Undelegated,
|
|
||||||
);
|
|
||||||
expect(undelegatedStakeBalance.currentEpochBalance).to.be.bignumber.equal(ZERO);
|
|
||||||
});
|
|
||||||
it('should read values correctly when in read-only mode', async () => {
|
|
||||||
// stake some zrx
|
|
||||||
const amountToStake = toBaseUnitAmount(10);
|
|
||||||
await stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amountToStake, {
|
|
||||||
from: actors[0],
|
|
||||||
});
|
|
||||||
// set to read-only mode
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(true);
|
|
||||||
// read stake balance in read-only mode
|
|
||||||
const undelegatedStakeBalanceReadOnly = await stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync(
|
|
||||||
actors[0],
|
|
||||||
StakeStatus.Undelegated,
|
|
||||||
);
|
|
||||||
expect(undelegatedStakeBalanceReadOnly.currentEpochBalance).to.be.bignumber.equal(amountToStake);
|
|
||||||
});
|
|
||||||
it('should exit read-only mode', async () => {
|
|
||||||
// set to read-only mode
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(true);
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(false);
|
|
||||||
// try to stake
|
|
||||||
const amountToStake = toBaseUnitAmount(10);
|
|
||||||
await stakingApiWrapper.stakingContract.stake.awaitTransactionSuccessAsync(amountToStake, {
|
|
||||||
from: actors[0],
|
|
||||||
});
|
|
||||||
const undelegatedStakeBalance = await stakingApiWrapper.stakingContract.getOwnerStakeByStatus.callAsync(
|
|
||||||
actors[0],
|
|
||||||
StakeStatus.Undelegated,
|
|
||||||
);
|
|
||||||
expect(undelegatedStakeBalance.currentEpochBalance).to.be.bignumber.equal(amountToStake);
|
|
||||||
});
|
|
||||||
it('should emit event and store correct configuration when setting read-only mode', async () => {
|
|
||||||
// set to read-only mode
|
|
||||||
const txReceipt = await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
expect(txReceipt.logs.length).to.be.equal(1);
|
|
||||||
const trueLog = txReceipt.logs[0] as LogWithDecodedArgs<StakingProxyReadOnlyModeSetEventArgs>;
|
|
||||||
expect(trueLog.args.readOnlyMode).to.be.true();
|
|
||||||
const timestamp = await env.web3Wrapper.getBlockTimestampAsync(txReceipt.blockNumber);
|
|
||||||
expect(trueLog.args.timestamp).to.bignumber.equal(timestamp);
|
|
||||||
const readOnlyState = await stakingApiWrapper.stakingProxyContract.readOnlyState.callAsync();
|
|
||||||
expect(readOnlyState[0]).to.be.true();
|
|
||||||
expect(readOnlyState[1]).to.bignumber.equal(timestamp);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// tslint:enable:no-unnecessary-type-assertion
|
|
||||||
@@ -108,7 +108,6 @@ blockchainTests('Migration tests', env => {
|
|||||||
env.txDefaults,
|
env.txDefaults,
|
||||||
artifacts,
|
artifacts,
|
||||||
stakingContract.address,
|
stakingContract.address,
|
||||||
stakingContract.address,
|
|
||||||
)).address;
|
)).address;
|
||||||
|
|
||||||
const stakingProxyContract = new StakingContract(
|
const stakingProxyContract = new StakingContract(
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import {
|
|||||||
artifacts,
|
artifacts,
|
||||||
IStakingEventsEpochEndedEventArgs,
|
IStakingEventsEpochEndedEventArgs,
|
||||||
IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs,
|
IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs,
|
||||||
ReadOnlyProxyContract,
|
|
||||||
StakingProxyContract,
|
StakingProxyContract,
|
||||||
TestCobbDouglasContract,
|
TestCobbDouglasContract,
|
||||||
TestStakingContract,
|
TestStakingContract,
|
||||||
TestStakingEvents,
|
TestStakingEvents,
|
||||||
ZrxVaultBackstopContract,
|
|
||||||
ZrxVaultContract,
|
ZrxVaultContract,
|
||||||
} from '../../src';
|
} from '../../src';
|
||||||
|
|
||||||
@@ -33,7 +31,6 @@ export class StakingApiWrapper {
|
|||||||
public zrxTokenContract: DummyERC20TokenContract;
|
public zrxTokenContract: DummyERC20TokenContract;
|
||||||
public wethContract: WETH9Contract;
|
public wethContract: WETH9Contract;
|
||||||
public cobbDouglasContract: TestCobbDouglasContract;
|
public cobbDouglasContract: TestCobbDouglasContract;
|
||||||
public zrxVaultBackstopContract: ZrxVaultBackstopContract;
|
|
||||||
public utils = {
|
public utils = {
|
||||||
// Epoch Utils
|
// Epoch Utils
|
||||||
fastForwardToNextEpochAsync: async (): Promise<void> => {
|
fastForwardToNextEpochAsync: async (): Promise<void> => {
|
||||||
@@ -176,14 +173,12 @@ export class StakingApiWrapper {
|
|||||||
zrxTokenContract: DummyERC20TokenContract,
|
zrxTokenContract: DummyERC20TokenContract,
|
||||||
wethContract: WETH9Contract,
|
wethContract: WETH9Contract,
|
||||||
cobbDouglasContract: TestCobbDouglasContract,
|
cobbDouglasContract: TestCobbDouglasContract,
|
||||||
zrxVaultBackstopContract: ZrxVaultBackstopContract,
|
|
||||||
) {
|
) {
|
||||||
this._web3Wrapper = env.web3Wrapper;
|
this._web3Wrapper = env.web3Wrapper;
|
||||||
this.zrxVaultContract = zrxVaultContract;
|
this.zrxVaultContract = zrxVaultContract;
|
||||||
this.zrxTokenContract = zrxTokenContract;
|
this.zrxTokenContract = zrxTokenContract;
|
||||||
this.wethContract = wethContract;
|
this.wethContract = wethContract;
|
||||||
this.cobbDouglasContract = cobbDouglasContract;
|
this.cobbDouglasContract = cobbDouglasContract;
|
||||||
this.zrxVaultBackstopContract = zrxVaultBackstopContract;
|
|
||||||
this.stakingContractAddress = stakingContract.address;
|
this.stakingContractAddress = stakingContract.address;
|
||||||
this.stakingProxyContract = stakingProxyContract;
|
this.stakingProxyContract = stakingProxyContract;
|
||||||
// disguise the staking proxy as a StakingContract
|
// disguise the staking proxy as a StakingContract
|
||||||
@@ -249,14 +244,6 @@ export async function deployAndConfigureContractsAsync(
|
|||||||
zrxVaultContract.address,
|
zrxVaultContract.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
// deploy read-only proxy
|
|
||||||
const readOnlyProxyContract = await ReadOnlyProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ReadOnlyProxy,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
|
|
||||||
// deploy staking proxy
|
// deploy staking proxy
|
||||||
const stakingProxyContract = await StakingProxyContract.deployFrom0xArtifactAsync(
|
const stakingProxyContract = await StakingProxyContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.StakingProxy,
|
artifacts.StakingProxy,
|
||||||
@@ -264,7 +251,6 @@ export async function deployAndConfigureContractsAsync(
|
|||||||
env.txDefaults,
|
env.txDefaults,
|
||||||
artifacts,
|
artifacts,
|
||||||
stakingContract.address,
|
stakingContract.address,
|
||||||
readOnlyProxyContract.address,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await stakingProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress);
|
await stakingProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(ownerAddress);
|
||||||
@@ -277,23 +263,10 @@ export async function deployAndConfigureContractsAsync(
|
|||||||
artifacts,
|
artifacts,
|
||||||
);
|
);
|
||||||
|
|
||||||
const zrxVaultBackstopContract = await ZrxVaultBackstopContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ZrxVaultBackstop,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
stakingProxyContract.address,
|
|
||||||
zrxVaultContract.address,
|
|
||||||
);
|
|
||||||
|
|
||||||
// configure erc20 proxy to accept calls from zrx vault
|
// configure erc20 proxy to accept calls from zrx vault
|
||||||
await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVaultContract.address);
|
await erc20ProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVaultContract.address);
|
||||||
// set staking proxy contract in zrx vault
|
// set staking proxy contract in zrx vault
|
||||||
await zrxVaultContract.setStakingProxy.awaitTransactionSuccessAsync(stakingProxyContract.address);
|
await zrxVaultContract.setStakingProxy.awaitTransactionSuccessAsync(stakingProxyContract.address);
|
||||||
// add zrxVaultBackstop as an authorized address
|
|
||||||
await zrxVaultContract.addAuthorizedAddress.awaitTransactionSuccessAsync(zrxVaultBackstopContract.address, {
|
|
||||||
from: ownerAddress,
|
|
||||||
});
|
|
||||||
return new StakingApiWrapper(
|
return new StakingApiWrapper(
|
||||||
env,
|
env,
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
@@ -303,6 +276,5 @@ export async function deployAndConfigureContractsAsync(
|
|||||||
zrxTokenContract,
|
zrxTokenContract,
|
||||||
wethContract,
|
wethContract,
|
||||||
cobbDouglasContract,
|
cobbDouglasContract,
|
||||||
zrxVaultBackstopContract,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
|
||||||
import { blockchainTests, describe, expect, increaseTimeAndMineBlockAsync } from '@0x/contracts-test-utils';
|
|
||||||
import { StringRevertError } from '@0x/utils';
|
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
|
||||||
|
|
||||||
import { ZrxVaultInCatastrophicFailureModeEventArgs } from '../src';
|
|
||||||
|
|
||||||
import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper';
|
|
||||||
blockchainTests.resets('ZrxVaultBackstop', env => {
|
|
||||||
let stakingApiWrapper: StakingApiWrapper;
|
|
||||||
let authorizedAddress: string;
|
|
||||||
let notAuthorizedAddress: string;
|
|
||||||
before(async () => {
|
|
||||||
const accounts = await env.web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
[authorizedAddress, notAuthorizedAddress] = accounts;
|
|
||||||
const erc20Wrapper = new ERC20Wrapper(env.provider, [], authorizedAddress);
|
|
||||||
stakingApiWrapper = await deployAndConfigureContractsAsync(env, authorizedAddress, erc20Wrapper);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('enterCatastrophicFailureIfProlongedReadOnlyMode', () => {
|
|
||||||
it('should revert if read-only mode is not set', async () => {
|
|
||||||
const expectedError = new StringRevertError('READ_ONLY_MODE_NOT_SET');
|
|
||||||
expect(
|
|
||||||
stakingApiWrapper.zrxVaultBackstopContract.enterCatastrophicFailureIfProlongedReadOnlyMode.awaitTransactionSuccessAsync(),
|
|
||||||
).to.revertWith(expectedError);
|
|
||||||
});
|
|
||||||
it('should revert if read-only mode has been set for less than 40 days', async () => {
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(true, {
|
|
||||||
from: authorizedAddress,
|
|
||||||
});
|
|
||||||
const expectedError = new StringRevertError('READ_ONLY_MODE_DURATION_TOO_SHORT');
|
|
||||||
expect(
|
|
||||||
stakingApiWrapper.zrxVaultBackstopContract.enterCatastrophicFailureIfProlongedReadOnlyMode.awaitTransactionSuccessAsync(),
|
|
||||||
).to.revertWith(expectedError);
|
|
||||||
});
|
|
||||||
it('should enter catastophic failure mode if read-only mode has been set for 40 days', async () => {
|
|
||||||
await stakingApiWrapper.stakingProxyContract.setReadOnlyMode.awaitTransactionSuccessAsync(true, {
|
|
||||||
from: authorizedAddress,
|
|
||||||
});
|
|
||||||
const fourtyDaysInSec = 40 * 24 * 60 * 60;
|
|
||||||
await increaseTimeAndMineBlockAsync(fourtyDaysInSec);
|
|
||||||
const txReceipt = await stakingApiWrapper.zrxVaultBackstopContract.enterCatastrophicFailureIfProlongedReadOnlyMode.awaitTransactionSuccessAsync(
|
|
||||||
{ from: notAuthorizedAddress },
|
|
||||||
);
|
|
||||||
expect(txReceipt.logs.length).to.equal(1);
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
|
||||||
const logArgs = (txReceipt.logs[0] as LogWithDecodedArgs<ZrxVaultInCatastrophicFailureModeEventArgs>).args;
|
|
||||||
expect(logArgs.sender).to.equal(stakingApiWrapper.zrxVaultBackstopContract.address);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
"generated-artifacts/IStorageInit.json",
|
"generated-artifacts/IStorageInit.json",
|
||||||
"generated-artifacts/IStructs.json",
|
"generated-artifacts/IStructs.json",
|
||||||
"generated-artifacts/IZrxVault.json",
|
"generated-artifacts/IZrxVault.json",
|
||||||
"generated-artifacts/IZrxVaultBackstop.json",
|
|
||||||
"generated-artifacts/LibCobbDouglas.json",
|
"generated-artifacts/LibCobbDouglas.json",
|
||||||
"generated-artifacts/LibFixedMath.json",
|
"generated-artifacts/LibFixedMath.json",
|
||||||
"generated-artifacts/LibFixedMathRichErrors.json",
|
"generated-artifacts/LibFixedMathRichErrors.json",
|
||||||
@@ -32,7 +31,6 @@
|
|||||||
"generated-artifacts/MixinStakingPool.json",
|
"generated-artifacts/MixinStakingPool.json",
|
||||||
"generated-artifacts/MixinStakingPoolRewards.json",
|
"generated-artifacts/MixinStakingPoolRewards.json",
|
||||||
"generated-artifacts/MixinStorage.json",
|
"generated-artifacts/MixinStorage.json",
|
||||||
"generated-artifacts/ReadOnlyProxy.json",
|
|
||||||
"generated-artifacts/Staking.json",
|
"generated-artifacts/Staking.json",
|
||||||
"generated-artifacts/StakingProxy.json",
|
"generated-artifacts/StakingProxy.json",
|
||||||
"generated-artifacts/TestAssertStorageParams.json",
|
"generated-artifacts/TestAssertStorageParams.json",
|
||||||
@@ -55,8 +53,7 @@
|
|||||||
"generated-artifacts/TestStakingNoWETH.json",
|
"generated-artifacts/TestStakingNoWETH.json",
|
||||||
"generated-artifacts/TestStakingProxy.json",
|
"generated-artifacts/TestStakingProxy.json",
|
||||||
"generated-artifacts/TestStorageLayoutAndConstants.json",
|
"generated-artifacts/TestStorageLayoutAndConstants.json",
|
||||||
"generated-artifacts/ZrxVault.json",
|
"generated-artifacts/ZrxVault.json"
|
||||||
"generated-artifacts/ZrxVaultBackstop.json"
|
|
||||||
],
|
],
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user