aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-05-25 01:24:32 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-05-31 08:11:31 +0800
commit9f93d8f53380bf650702c653fea13b3e7ed5f8f7 (patch)
tree5562e78903d0d6cb41ad33afa63f154566f639f5 /packages/contracts
parent6050a59e4a190cf8f8d42e390b435a7184b8f718 (diff)
downloaddexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar.gz
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar.bz2
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar.lz
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar.xz
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.tar.zst
dexon-sol-tools-9f93d8f53380bf650702c653fea13b3e7ed5f8f7.zip
Fix formatting and tests
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol4
-rw-r--r--packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol2
-rw-r--r--packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol6
-rw-r--r--packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol2
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts6
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts6
-rw-r--r--packages/contracts/test/ether_token.ts6
-rw-r--r--packages/contracts/test/exchange/core.ts6
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts6
-rw-r--r--packages/contracts/test/exchange/libs.ts10
-rw-r--r--packages/contracts/test/exchange/match_orders.ts6
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts7
-rw-r--r--packages/contracts/test/exchange/transactions.ts13
-rw-r--r--packages/contracts/test/exchange/wrapper.ts6
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts6
-rw-r--r--packages/contracts/test/token_registry.ts6
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts6
-rw-r--r--packages/contracts/test/zrx_token.ts6
18 files changed, 16 insertions, 94 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
index 96a1f578a..4b0b1d02d 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
@@ -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);
}
}
diff --git a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol b/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol
index b835e70d0..69554605d 100644
--- a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol
+++ b/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol
@@ -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);
diff --git a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol b/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol
index e2bc75b37..0f84678cf 100644
--- a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol
+++ b/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol
@@ -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,
diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
index 8b9763c65..0594e2767 100644
--- a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
+++ b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
@@ -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.
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 87f89c513..1b7f2bdaf 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -20,12 +20,6 @@ describe('Authorizable', () => {
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];
notOwner = accounts[1];
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 9bcdfa2b8..cecc75937 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -37,12 +37,6 @@ describe('Asset Transfer Proxies', () => {
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);
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index 10dd635fe..84b43e05a 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -20,12 +20,6 @@ describe('EtherToken', () => {
let etherToken: WETH9Contract;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0];
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index bc476a5ee..70f9ff915 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -61,12 +61,6 @@ describe('Exchange core', () => {
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);
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index b9c7039bd..66407322b 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -36,12 +36,6 @@ describe('AssetProxyDispatcher', () => {
let erc721Wrapper: ERC721Wrapper;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
// Setup accounts & addresses
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, notOwner, makerAddress, takerAddress] = accounts);
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index bbca54274..c6c07f633 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -25,12 +25,6 @@ describe('Exchange libs', () => {
let libs: TestLibsContract;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
@@ -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);
});
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index 0da0287bc..754a73d78 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -77,12 +77,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();
const usedAddresses = ([
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index ca679e344..08de05047 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -25,12 +25,6 @@ describe('MixinSignatureValidator', () => {
let signatureValidator: TestSignatureValidatorContract;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
signatureValidator = await TestSignatureValidatorContract.deployFrom0xArtifactAsync(
@@ -53,7 +47,6 @@ describe('MixinSignatureValidator', () => {
beforeEach(async () => {
await blockchainLifecycle.startAsync();
- signedOrder = orderFactory.newSignedOrder();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 294e3aae9..0d10f6723 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -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';
@@ -60,12 +61,6 @@ describe('Exchange transactions', () => {
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,
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 7e1818f4a..8c27d993e 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -55,12 +55,6 @@ describe('Exchange wrappers', () => {
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);
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index e817951ab..ab92dfc8c 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -34,12 +34,6 @@ describe('LibBytes', () => {
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();
owner = accounts[0];
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index 1cc519c53..df835d8f4 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -24,12 +24,6 @@ describe('TokenRegistry', () => {
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];
notOwner = accounts[1];
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index c68d8bdcf..ab001b770 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -22,12 +22,6 @@ describe('UnlimitedAllowanceToken', () => {
let token: DummyERC20TokenContract;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index fe37e802b..a159b6ed5 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -22,12 +22,6 @@ describe('ZRXToken', () => {
let zrxToken: ZRXTokenContract;
before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];