Fixed the tests by using the IsolatedExchange

This commit is contained in:
Alex Towle
2019-08-03 01:52:17 -07:00
parent a7520eeaa8
commit cdabe21e7a
5 changed files with 29 additions and 44 deletions

View File

@@ -14,18 +14,13 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "../src/Exchange.sol";
import "./IsolatedExchange.sol";
// solhint-disable no-empty-blocks
contract TestMatchOrders is
Exchange
IsolatedExchange
{
constructor (uint256 chainId)
public
Exchange(chainId)
{}
function publicCalculateMatchedFillResults(
LibOrder.Order memory leftOrder,
LibOrder.Order memory rightOrder,
@@ -86,6 +81,4 @@ contract TestMatchOrders is
rightTakerAssetAmountRemaining
);
}
// FIXME - Stub out _dispatchTransferFrom
}

View File

@@ -34,7 +34,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IWallet|IWrapperFunctions|IsolatedExchange|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestValidatorWallet|TestWrapperFunctions|Whitelist).json",
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IWallet|IWrapperFunctions|IsolatedExchange|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestMatchOrders|TestSignatureValidator|TestValidatorWallet|TestWrapperFunctions|Whitelist).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {

View File

@@ -30,7 +30,6 @@ export const artifacts = {
ExchangeWrapper: ExchangeWrapper as ContractArtifact,
Whitelist: Whitelist as ContractArtifact,
Exchange: Exchange as ContractArtifact,
MixinMatchOrders: MixinMatchOrders as ContractArtifact,
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
IEIP1271Wallet: IEIP1271Wallet as ContractArtifact,
IExchange: IExchange as ContractArtifact,

View File

@@ -11,9 +11,12 @@ import {
import { ERC1155Contract as ERC1155TokenContract, Erc1155Wrapper as ERC1155Wrapper } from '@0x/contracts-erc1155';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import { ReferenceFunctions as ExchangeLibsReferenceFunctions } from '@0x/contracts-exchange-libs';
import {
blockchainTests,
chaiSetup,
constants,
describe,
OrderFactory,
orderUtils,
provider,
@@ -34,15 +37,12 @@ import {
ExchangeContract,
ExchangeWrapper,
ReentrantERC20TokenContract,
ReferenceFunctions,
TestMatchOrdersContract,
} from '../src';
import { MatchOrderTester, TokenBalances } from './utils/match_order_tester';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
const expect = chai.expect;
// Reduce the number of tokens to deploy to speed up tests, since we don't need
// so many.
constants.NUM_DUMMY_ERC721_TO_DEPLOY = 1;
@@ -116,29 +116,29 @@ async function testCalculateCompleteFillBothAsync(
* @param rightMakerAssetAmountRemaining The right maker asset remaining field for the function call.
* @param rightTakerAssetAmountRemaining The right taker asset remaining field for the function call.
*/
async function testCalculateCompleteRightFillAsync(
matchOrders: TestMatchOrdersContract,
leftOrder: SignedOrder,
args: BigNumber[],
): Promise<void> {
// Ensure that the correct number of arguments were provided.
expect(args.length).to.be.eq(2);
//async function testCalculateCompleteRightFillAsync(
// matchOrders: TestMatchOrdersContract,
// leftOrder: SignedOrder,
// args: BigNumber[],
//): Promise<void> {
// // Ensure that the correct number of arguments were provided.
// expect(args.length).to.be.eq(2);
//
// // Get the resultant matched fill results from the call to _calculateCompleteFillBoth.
// const matchedFillResults = await matchOrders.externalCalculateCompleteFillBoth.callAsync(
// leftOrder,
// args[0],
// args[1],
// );
//
// // Ensure that the matched fill results are correct.
// expect(matchedFillResults.left.makerAssetFilledAmount).bignumber.to.be.eq(args[0]);
// expect(matchedFillResults.left.takerAssetFilledAmount).bignumber.to.be.eq(args[1]);
// expect(matchedFillResults.right.makerAssetFilledAmount).bignumber.to.be.eq(args[2]);
// expect(matchedFillResults.right.takerAssetFilledAmount).bignumber.to.be.eq(args[3]);
//}
// Get the resultant matched fill results from the call to _calculateCompleteFillBoth.
const matchedFillResults = await matchOrders.externalCalculateCompleteFillBoth.callAsync(
leftOrder,
args[0],
args[1],
);
// Ensure that the matched fill results are correct.
expect(matchedFillResults.left.makerAssetFilledAmount).bignumber.to.be.eq(args[0]);
expect(matchedFillResults.left.takerAssetFilledAmount).bignumber.to.be.eq(args[1]);
expect(matchedFillResults.right.makerAssetFilledAmount).bignumber.to.be.eq(args[2]);
expect(matchedFillResults.right.takerAssetFilledAmount).bignumber.to.be.eq(args[3]);
}
describe.only('matchOrders', () => {
blockchainTests.resets.only('MatchOrders Tests', ({ web3Wrapper, txDefaults }) => {
let chainId: number;
let makerAddressLeft: string;
let makerAddressRight: string;
@@ -174,12 +174,6 @@ describe.only('matchOrders', () => {
let matchOrders: TestMatchOrdersContract;
before(async () => {
await blockchainLifecycle.startAsync();
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
before(async () => {
// Get the chain ID.
chainId = await providerUtils.getChainIdAsync(provider);
@@ -330,7 +324,6 @@ describe.only('matchOrders', () => {
artifacts.TestMatchOrders,
provider,
txDefaults,
new BigNumber(chainId),
);
});

Binary file not shown.