Fix tests

This commit is contained in:
Amir Bandeali
2019-09-20 12:46:04 -07:00
parent 7b81af2cb4
commit a1ed7183ea
2 changed files with 20 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
import { blockchainTests, constants, expect, filterLogsToArguments, randomAddress } from '@0x/contracts-test-utils'; import { blockchainTests, constants, expect, filterLogsToArguments, randomAddress } from '@0x/contracts-test-utils';
import { StakingRevertErrors } from '@0x/order-utils'; import { StakingRevertErrors } from '@0x/order-utils';
import { BigNumber, OwnableRevertErrors, StringRevertError } from '@0x/utils'; import { AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils';
import { import {
artifacts, artifacts,
@@ -16,13 +16,13 @@ import {
import { constants as stakingConstants } from './utils/constants'; import { constants as stakingConstants } from './utils/constants';
blockchainTests('Migration tests', env => { blockchainTests('Migration tests', env => {
let ownerAddress: string; let authorizedAddress: string;
let notOwnerAddress: string; let notAuthorizedAddress: string;
let stakingContract: StakingContract; let stakingContract: StakingContract;
before(async () => { before(async () => {
[ownerAddress, notOwnerAddress] = await env.getAccountAddressesAsync(); [authorizedAddress, notAuthorizedAddress] = await env.getAccountAddressesAsync();
stakingContract = await StakingContract.deployFrom0xArtifactAsync( stakingContract = await StakingContract.deployFrom0xArtifactAsync(
artifacts.Staking, artifacts.Staking,
env.provider, env.provider,
@@ -48,7 +48,7 @@ blockchainTests('Migration tests', env => {
} }
before(async () => { before(async () => {
[ownerAddress, notOwnerAddress] = await env.getAccountAddressesAsync(); [authorizedAddress, notAuthorizedAddress] = await env.getAccountAddressesAsync();
initTargetContract = await TestInitTargetContract.deployFrom0xArtifactAsync( initTargetContract = await TestInitTargetContract.deployFrom0xArtifactAsync(
artifacts.TestInitTarget, artifacts.TestInitTarget,
env.provider, env.provider,
@@ -64,7 +64,7 @@ blockchainTests('Migration tests', env => {
await env.web3Wrapper.awaitTransactionMinedAsync( await env.web3Wrapper.awaitTransactionMinedAsync(
await env.web3Wrapper.sendTransactionAsync({ await env.web3Wrapper.sendTransactionAsync({
...env.txDefaults, ...env.txDefaults,
from: ownerAddress, from: authorizedAddress,
to: revertAddress, to: revertAddress,
data: constants.NULL_BYTES, data: constants.NULL_BYTES,
value: new BigNumber(1), value: new BigNumber(1),
@@ -76,7 +76,7 @@ blockchainTests('Migration tests', env => {
const [senderAddress, thisAddress] = await initTargetContract.getInitState.callAsync({ const [senderAddress, thisAddress] = await initTargetContract.getInitState.callAsync({
to: proxyContract.address, to: proxyContract.address,
}); });
expect(senderAddress).to.eq(ownerAddress); expect(senderAddress).to.eq(authorizedAddress);
expect(thisAddress).to.eq(proxyContract.address); expect(thisAddress).to.eq(proxyContract.address);
const attachedAddress = await proxyContract.stakingContract.callAsync(); const attachedAddress = await proxyContract.stakingContract.callAsync();
expect(attachedAddress).to.eq(initTargetContract.address); expect(attachedAddress).to.eq(initTargetContract.address);
@@ -144,7 +144,7 @@ blockchainTests('Migration tests', env => {
proxyContract = await deployStakingProxyAsync(); proxyContract = await deployStakingProxyAsync();
}); });
it('throws if not called by owner', async () => { it('throws if not called by an authorized address', async () => {
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync( const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
initTargetContract.address, initTargetContract.address,
constants.NULL_ADDRESS, constants.NULL_ADDRESS,
@@ -152,10 +152,10 @@ blockchainTests('Migration tests', env => {
constants.NULL_ADDRESS, constants.NULL_ADDRESS,
constants.NULL_ADDRESS, constants.NULL_ADDRESS,
{ {
from: notOwnerAddress, from: notAuthorizedAddress,
}, },
); );
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwnerAddress, ownerAddress); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress);
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
@@ -283,17 +283,17 @@ blockchainTests('Migration tests', env => {
}); });
blockchainTests.resets('Staking.init()', async () => { blockchainTests.resets('Staking.init()', async () => {
it('throws if not called by owner', async () => { it('throws if not called by an authorized address', async () => {
const tx = stakingContract.init.awaitTransactionSuccessAsync( const tx = stakingContract.init.awaitTransactionSuccessAsync(
randomAddress(), randomAddress(),
randomAddress(), randomAddress(),
randomAddress(), randomAddress(),
randomAddress(), randomAddress(),
{ {
from: notOwnerAddress, from: notAuthorizedAddress,
}, },
); );
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwnerAddress, ownerAddress); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress);
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });

View File

@@ -1,6 +1,6 @@
import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils'; import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
import { StakingRevertErrors } from '@0x/order-utils'; import { StakingRevertErrors } from '@0x/order-utils';
import { BigNumber, OwnableRevertErrors } from '@0x/utils'; import { AuthorizableRevertErrors, BigNumber } from '@0x/utils';
import { artifacts, IStakingEventsParamsSetEventArgs, MixinParamsContract } from '../src/'; import { artifacts, IStakingEventsParamsSetEventArgs, MixinParamsContract } from '../src/';
@@ -9,11 +9,11 @@ import { StakingParams } from './utils/types';
blockchainTests('Configurable Parameters', env => { blockchainTests('Configurable Parameters', env => {
let testContract: MixinParamsContract; let testContract: MixinParamsContract;
let ownerAddress: string; let authorizedAddress: string;
let notOwnerAddress: string; let notAuthorizedAddress: string;
before(async () => { before(async () => {
[ownerAddress, notOwnerAddress] = await env.getAccountAddressesAsync(); [authorizedAddress, notAuthorizedAddress] = await env.getAccountAddressesAsync();
testContract = await MixinParamsContract.deployFrom0xArtifactAsync( testContract = await MixinParamsContract.deployFrom0xArtifactAsync(
artifacts.MixinParams, artifacts.MixinParams,
env.provider, env.provider,
@@ -68,9 +68,9 @@ blockchainTests('Configurable Parameters', env => {
expect(actual[9]).to.eq(_params.zrxVaultAddress); expect(actual[9]).to.eq(_params.zrxVaultAddress);
} }
it('throws if not called by owner', async () => { it('throws if not called by an authorized address', async () => {
const tx = setParamsAndAssertAsync({}, notOwnerAddress); const tx = setParamsAndAssertAsync({}, notAuthorizedAddress);
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwnerAddress, ownerAddress); const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress);
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });