Fix formatting and tests
This commit is contained in:
@@ -104,7 +104,6 @@ contract MixinSignatureValidator is
|
||||
// it an explicit option. This aids testing and analysis. It is
|
||||
// also the initialization value for the enum type.
|
||||
if (signatureType == SignatureType.Illegal) {
|
||||
// NOTE: Reason cannot be assigned to a variable because of https://github.com/ethereum/solidity/issues/4051
|
||||
revert(ILLEGAL_SIGNATURE_TYPE);
|
||||
|
||||
// Always invalid signature.
|
||||
@@ -234,7 +233,6 @@ contract MixinSignatureValidator is
|
||||
// that we currently support. In this case returning false
|
||||
// may lead the caller to incorrectly believe that the
|
||||
// signature was invalid.)
|
||||
// NOTE: Reason cannot be assigned to a variable because of https://github.com/ethereum/solidity/issues/4051
|
||||
revert("Unsupported signature type.");
|
||||
revert(UNSUPPORTED_SIGNATURE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ contract TestLibBytes is
|
||||
/// @return The byte that was popped off.
|
||||
function publicPopByte(bytes memory b)
|
||||
public
|
||||
pure
|
||||
returns (bytes memory, bytes1 result)
|
||||
{
|
||||
result = popByte(b);
|
||||
@@ -41,6 +42,7 @@ contract TestLibBytes is
|
||||
/// @return The 20 byte address that was popped off.
|
||||
function publicPopAddress(bytes memory b)
|
||||
public
|
||||
pure
|
||||
returns (bytes memory, address result)
|
||||
{
|
||||
result = popAddress(b);
|
||||
|
||||
@@ -20,8 +20,12 @@ pragma solidity ^0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../../protocol/Exchange/MixinSignatureValidator.sol";
|
||||
import "../../protocol/Exchange/MixinTransactions.sol";
|
||||
|
||||
contract TestSignatureValidator is MixinSignatureValidator {
|
||||
contract TestSignatureValidator is
|
||||
MixinSignatureValidator,
|
||||
MixinTransactions
|
||||
{
|
||||
|
||||
function publicIsValidSignature(
|
||||
bytes32 hash,
|
||||
|
||||
@@ -114,6 +114,8 @@ contract Whitelist is
|
||||
}
|
||||
|
||||
/// @dev Verifies signer is same as signer of current Ethereum transaction.
|
||||
/// NOTE: This function can currently be used to validate signatures coming from outside of this contract.
|
||||
/// Extra safety checks can be added for a production contract.
|
||||
/// @param signer Address that should have signed the given hash.
|
||||
/// @param signature Proof of signing.
|
||||
/// @return Validity of order signature.
|
||||
|
||||
@@ -19,12 +19,6 @@ describe('Authorizable', () => {
|
||||
let notOwner: string;
|
||||
let address: string;
|
||||
let authorizable: MixinAuthorizableContract;
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = address = accounts[0];
|
||||
|
||||
@@ -36,12 +36,6 @@ describe('Asset Transfer Proxies', () => {
|
||||
let erc721Wrapper: ERC721Wrapper;
|
||||
let erc721MakerTokenId: BigNumber;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const usedAddresses = ([owner, notAuthorized, exchangeAddress, makerAddress, takerAddress] = accounts);
|
||||
|
||||
@@ -19,12 +19,6 @@ describe('EtherToken', () => {
|
||||
const gasPrice = Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 9);
|
||||
let etherToken: WETH9Contract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
account = accounts[0];
|
||||
|
||||
@@ -60,12 +60,6 @@ describe('Exchange core', () => {
|
||||
let defaultMakerAssetAddress: string;
|
||||
let defaultTakerAssetAddress: string;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
|
||||
|
||||
@@ -35,12 +35,6 @@ describe('AssetProxyDispatcher', () => {
|
||||
let erc20Wrapper: ERC20Wrapper;
|
||||
let erc721Wrapper: ERC721Wrapper;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Setup accounts & addresses
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
|
||||
@@ -24,12 +24,6 @@ describe('Exchange libs', () => {
|
||||
let orderFactory: OrderFactory;
|
||||
let libs: TestLibsContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const makerAddress = accounts[0];
|
||||
@@ -49,7 +43,6 @@ describe('Exchange libs', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
signedOrder = orderFactory.newSignedOrder();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
@@ -69,7 +62,8 @@ describe('Exchange libs', () => {
|
||||
});
|
||||
});
|
||||
describe('getOrderHash', () => {
|
||||
it('should output the correct order hash', async () => {
|
||||
it('should output the correct orderHash', async () => {
|
||||
signedOrder = orderFactory.newSignedOrder();
|
||||
const orderHashHex = await libs.publicGetOrderHash.callAsync(signedOrder);
|
||||
expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
|
||||
});
|
||||
|
||||
@@ -76,12 +76,6 @@ describe('matchOrders', () => {
|
||||
|
||||
let matchOrderTester: MatchOrderTester;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Create accounts
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
|
||||
@@ -24,12 +24,6 @@ describe('MixinSignatureValidator', () => {
|
||||
let orderFactory: OrderFactory;
|
||||
let signatureValidator: TestSignatureValidatorContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const makerAddress = accounts[0];
|
||||
@@ -53,7 +47,6 @@ describe('MixinSignatureValidator', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
signedOrder = orderFactory.newSignedOrder();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { Order, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -59,12 +60,6 @@ describe('Exchange transactions', () => {
|
||||
let makerPrivateKey: Buffer;
|
||||
let takerPrivateKey: Buffer;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const usedAddresses = ([owner, senderAddress, makerAddress, takerAddress, feeRecipientAddress] = accounts);
|
||||
@@ -245,7 +240,7 @@ describe('Exchange transactions', () => {
|
||||
|
||||
const orderStruct = orderUtils.getOrderStruct(signedOrder);
|
||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||
const salt = ZeroEx.generatePseudoRandomSalt();
|
||||
const salt = generatePseudoRandomSalt();
|
||||
return expect(
|
||||
whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
|
||||
orderStruct,
|
||||
@@ -263,7 +258,7 @@ describe('Exchange transactions', () => {
|
||||
|
||||
const orderStruct = orderUtils.getOrderStruct(signedOrder);
|
||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||
const salt = ZeroEx.generatePseudoRandomSalt();
|
||||
const salt = generatePseudoRandomSalt();
|
||||
return expect(
|
||||
whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
|
||||
orderStruct,
|
||||
@@ -282,7 +277,7 @@ describe('Exchange transactions', () => {
|
||||
|
||||
const orderStruct = orderUtils.getOrderStruct(signedOrder);
|
||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||
const salt = ZeroEx.generatePseudoRandomSalt();
|
||||
const salt = generatePseudoRandomSalt();
|
||||
await whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
|
||||
orderStruct,
|
||||
takerAssetFillAmount,
|
||||
|
||||
@@ -54,12 +54,6 @@ describe('Exchange wrappers', () => {
|
||||
let defaultMakerAssetAddress: string;
|
||||
let defaultTakerAssetAddress: string;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
|
||||
|
||||
@@ -33,12 +33,6 @@ describe('LibBytes', () => {
|
||||
const testBytes32 = '0x102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f01020';
|
||||
const testUint256 = new BigNumber(testBytes32, 16);
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Setup accounts & addresses
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
|
||||
@@ -23,12 +23,6 @@ describe('TokenRegistry', () => {
|
||||
let notOwner: string;
|
||||
let tokenReg: TokenRegistryContract;
|
||||
let tokenRegWrapper: TokenRegWrapper;
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
|
||||
@@ -21,12 +21,6 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
|
||||
let token: DummyERC20TokenContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
|
||||
@@ -21,12 +21,6 @@ describe('ZRXToken', () => {
|
||||
let MAX_UINT: BigNumber;
|
||||
let zrxToken: ZRXTokenContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
|
||||
Reference in New Issue
Block a user