Merge pull request #2368 from 0xProject/fix/reenable-builds-for-v3
Reenable CircleCi tests for swapper + orderbook, and fix migrations bug
This commit is contained in:
commit
5fbdfa66d9
@ -116,22 +116,15 @@ jobs:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn wsrun test:circleci @0x/contracts-test-utils
|
||||
- run: yarn wsrun test:circleci @0x/abi-gen
|
||||
# TODO (xianny): Needs to be updated for 3.0
|
||||
# - run: yarn wsrun test:circleci @0x/asset-buyer
|
||||
# TODO: Needs to be updated for 3.0. At that time, also remove
|
||||
# exclusion from monorepo package.json's test script.
|
||||
# - run: yarn wsrun test:circleci @0x/asset-swapper
|
||||
- run: yarn wsrun test:circleci @0x/asset-swapper
|
||||
- run: yarn wsrun test:circleci @0x/contract-artifacts
|
||||
- run: yarn wsrun test:circleci @0x/assert
|
||||
- run: yarn wsrun test:circleci @0x/base-contract
|
||||
# TODO (xianny): Needs to be updated for 3.0
|
||||
# - run: yarn wsrun test:circleci @0x/connect
|
||||
- run: yarn wsrun test:circleci @0x/connect
|
||||
- run: yarn wsrun test:circleci @0x/contract-wrappers
|
||||
- run: yarn wsrun test:circleci @0x/dev-utils
|
||||
- run: yarn wsrun test:circleci @0x/json-schemas
|
||||
- run: yarn wsrun test:circleci @0x/order-utils
|
||||
# TODO: Needs to be updated for 3.0. At that time, also remove
|
||||
# exclusion from monorepo package.json's test script.
|
||||
# - run: yarn wsrun test:circleci @0x/orderbook
|
||||
- run: yarn wsrun test:circleci @0x/sol-compiler
|
||||
- run: yarn wsrun test:circleci @0x/sol-tracing-utils
|
||||
|
0
packages/asset-swapper/coverage/.gitkeep
Normal file
0
packages/asset-swapper/coverage/.gitkeep
Normal file
@ -99,7 +99,7 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
||||
) => Promise<void>;
|
||||
|
||||
before(async () => {
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
contractAddresses = await migrateOnceAsync(provider);
|
||||
await blockchainLifecycle.startAsync();
|
||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
[coinbaseAddress, takerAddress, makerAddress, feeRecipient] = userAddresses;
|
||||
|
@ -31,9 +31,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
const GAS_PRICE = new BigNumber(devConstants.DEFAULT_GAS_PRICE);
|
||||
const ONE_ETH_IN_WEI = new BigNumber(1000000000000000000);
|
||||
const TESTRPC_CHAIN_ID = devConstants.TESTRPC_CHAIN_ID;
|
||||
const FILLABLE_AMOUNTS = [new BigNumber(2), new BigNumber(3), new BigNumber(5)].map(value =>
|
||||
value.multipliedBy(ONE_ETH_IN_WEI),
|
||||
);
|
||||
|
||||
const UNLIMITED_ALLOWANCE_IN_BASE_UNITS = new BigNumber(2).pow(256).minus(1); // tslint:disable-line:custom-no-magic-numbers
|
||||
|
||||
const PARTIAL_PRUNED_SIGNED_ORDERS_FEELESS: Array<Partial<PrunedSignedOrder>> = [
|
||||
@ -99,7 +97,7 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
const chainId = TESTRPC_CHAIN_ID;
|
||||
|
||||
before(async () => {
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
contractAddresses = await migrateOnceAsync(provider);
|
||||
await blockchainLifecycle.startAsync();
|
||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
[coinbaseAddress, takerAddress, makerAddress, feeRecipient] = userAddresses;
|
||||
@ -149,10 +147,7 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
const UNLIMITED_ALLOWANCE = UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||
|
||||
const totalFillableAmount = FILLABLE_AMOUNTS.reduce(
|
||||
(a: BigNumber, c: BigNumber) => a.plus(c),
|
||||
new BigNumber(0),
|
||||
);
|
||||
const totalFillableAmount = new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI);
|
||||
|
||||
await erc20TokenContract.transfer(makerAddress, totalFillableAmount).sendTransactionAsync({
|
||||
from: coinbaseAddress,
|
||||
@ -241,6 +236,7 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
takerAddress,
|
||||
gasPrice: GAS_PRICE,
|
||||
gasLimit: 4000000,
|
||||
ethAmount: new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI),
|
||||
});
|
||||
await expectMakerAndTakerBalancesAsync(
|
||||
constants.ZERO_AMOUNT,
|
||||
|
@ -64,7 +64,7 @@ describe('OrderPruner', () => {
|
||||
const takerFeeAmount = new BigNumber(2).multipliedBy(ONE_ETH_IN_WEI);
|
||||
|
||||
before(async () => {
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
contractAddresses = await migrateOnceAsync(provider);
|
||||
await blockchainLifecycle.startAsync();
|
||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
[coinbaseAddress, takerAddress, makerAddress, feeRecipient] = userAddresses;
|
||||
|
@ -83,7 +83,7 @@ describe('swapQuoteConsumerUtils', () => {
|
||||
|
||||
const chainId = TESTRPC_CHAIN_ID;
|
||||
before(async () => {
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
contractAddresses = await migrateOnceAsync(provider);
|
||||
await blockchainLifecycle.startAsync();
|
||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const devUtils = new DevUtilsContract(contractAddresses.devUtils, provider);
|
||||
|
@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "3.3.0-beta.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "`1337` addresses updated with Forwarder deployed after Exchange is configured",
|
||||
"pr": 2368
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.3.0-beta.4",
|
||||
"changes": [
|
||||
|
@ -105,22 +105,22 @@
|
||||
"erc1155Proxy": "0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8",
|
||||
"zrxToken": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c",
|
||||
"etherToken": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082",
|
||||
"exchangeV2": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
|
||||
"exchange": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
|
||||
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
|
||||
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0xaa86dda78e9434aca114b6676fc742a18d15a1cc",
|
||||
"erc20BridgeProxy": "0x8ea76477cfaca8f7ea06477fd3c09a740ac6012a",
|
||||
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0x5d3ad3561a1235273cbcb4e82fce63a0073d19be",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"coordinatorRegistry": "0x1941ff73d1154774d87521d2d0aaad5d19c8df60",
|
||||
"coordinator": "0x0d8b0dd11f5d34ed41d556def5f841900d5b1c6b",
|
||||
"coordinatorRegistry": "0xaa86dda78e9434aca114b6676fc742a18d15a1cc",
|
||||
"coordinator": "0x4d3d5c850dd5bd9d6f4adda3dd039a3c8054ca29",
|
||||
"multiAssetProxy": "0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db",
|
||||
"staticCallProxy": "0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f",
|
||||
"devUtils": "0x38ef19fdf8e8415f18c307ed71967e19aac28ba1",
|
||||
"zrxVault": "0x609acc8b356894a937fc58f3411f9528de96ecb1",
|
||||
"staking": "0xca9717a4a6e8009b3518648c9f3e7676255471a1",
|
||||
"stakingProxy": "0x4586649629f699f9a4b61d0e962dc3c9025fe488",
|
||||
"erc20BridgeProxy": "0xf23276778860e420acfc18ebeebf7e829b06965c",
|
||||
"devUtils": "0xa31e64ea55b9b6bbb9d6a676738e9a5b23149f84",
|
||||
"exchangeV2": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
|
||||
"zrxVault": "0x1941ff73d1154774d87521d2d0aaad5d19c8df60",
|
||||
"staking": "0x0d8b0dd11f5d34ed41d556def5f841900d5b1c6b",
|
||||
"stakingProxy": "0x38ef19fdf8e8415f18c307ed71967e19aac28ba1",
|
||||
"uniswapBridge": "0x0000000000000000000000000000000000000000",
|
||||
"eth2DaiBridge": "0x0000000000000000000000000000000000000000"
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ describe('ABI Decoding Calldata', () => {
|
||||
chainId,
|
||||
};
|
||||
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
contractAddresses = await migrateOnceAsync(provider);
|
||||
await blockchainLifecycle.startAsync();
|
||||
const config = {
|
||||
chainId: constants.TESTRPC_CHAIN_ID,
|
||||
|
@ -1,4 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "4.4.0-beta.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Deploy Forwarder after Exchange is configured as Staking Proxy is queried",
|
||||
"pr": 2368
|
||||
},
|
||||
{
|
||||
"note": "Subsequent contract addresses after the Forwarder are now modified",
|
||||
"pr": 2368
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "4.4.0-beta.3",
|
||||
"changes": [
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ContractAddresses } from '@0x/contract-addresses';
|
||||
import { devConstants, web3Factory } from '@0x/dev-utils';
|
||||
import { devConstants } from '@0x/dev-utils';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
|
||||
import { runMigrationsOnceAsync } from './index';
|
||||
@ -9,11 +9,10 @@ import { runMigrationsOnceAsync } from './index';
|
||||
* called, it returns the cached addresses.
|
||||
* @returns The addresses of contracts that were deployed during the migrations.
|
||||
*/
|
||||
export async function migrateOnceAsync(): Promise<ContractAddresses> {
|
||||
export async function migrateOnceAsync(provider: Web3ProviderEngine): Promise<ContractAddresses> {
|
||||
const txDefaults = {
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
};
|
||||
const provider: Web3ProviderEngine = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
return runMigrationsOnceAsync(provider, txDefaults);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import { ForwarderContract } from '@0x/contracts-exchange-forwarder';
|
||||
import { StakingProxyContract, TestStakingContract, ZrxVaultContract } from '@0x/contracts-staking';
|
||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||
import { AbiEncoder, BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { MethodAbi, SupportedProvider, TxData } from 'ethereum-types';
|
||||
|
||||
import { constants } from './utils/constants';
|
||||
@ -65,7 +64,6 @@ export async function runMigrationsAsync(
|
||||
txDefaults: TxData,
|
||||
): Promise<ContractAddresses> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider));
|
||||
|
||||
// Proxies
|
||||
@ -176,22 +174,6 @@ export async function runMigrationsAsync(
|
||||
await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
||||
await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
||||
|
||||
// Forwarder
|
||||
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
||||
artifacts.Forwarder,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
exchange.address,
|
||||
encodeERC20AssetData(etherToken.address),
|
||||
);
|
||||
// Fake the above transactions so our nonce increases and we result with the same addresses
|
||||
// while AssetProxyOwner is disabled (TODO: @dekz remove)
|
||||
const dummyTransactionCount = 7;
|
||||
for (let index = 0; index <= dummyTransactionCount; index++) {
|
||||
await web3Wrapper.sendTransactionAsync({ to: txDefaults.from, from: txDefaults.from, value: new BigNumber(0) });
|
||||
}
|
||||
|
||||
// CoordinatorRegistry
|
||||
const coordinatorRegistry = await CoordinatorRegistryContract.deployFrom0xArtifactAsync(
|
||||
artifacts.CoordinatorRegistry,
|
||||
@ -281,6 +263,18 @@ export async function runMigrationsAsync(
|
||||
await stakingLogic.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync(txDefaults);
|
||||
await stakingLogic.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
|
||||
|
||||
// Forwarder
|
||||
// Deployed after Exchange and Staking is configured as it queries
|
||||
// in the constructor
|
||||
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
||||
artifacts.Forwarder,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
exchange.address,
|
||||
encodeERC20AssetData(etherToken.address),
|
||||
);
|
||||
|
||||
const contractAddresses = {
|
||||
erc20Proxy: erc20Proxy.address,
|
||||
erc721Proxy: erc721Proxy.address,
|
||||
|
@ -22,7 +22,7 @@ export type AddedRemovedListeners = (addedRemoved: AddedRemovedOrders) => void;
|
||||
* Constructor options for a SRA Websocket Order Provider
|
||||
*/
|
||||
export interface SRAWebsocketOrderProviderOpts {
|
||||
// The http endpoint to the SRA service, e.g https://sra.0x.org/v2
|
||||
// The http endpoint to the SRA service, e.g https://sra.0x.org/v3
|
||||
httpEndpoint: string;
|
||||
// The websocket endpoint to the SRA service, e.g wss://ws.sra.0x.org/
|
||||
websocketEndpoint: string;
|
||||
@ -32,7 +32,7 @@ export interface SRAWebsocketOrderProviderOpts {
|
||||
* Constructor options for a SRA Polling Order Provider
|
||||
*/
|
||||
export interface SRAPollingOrderProviderOpts {
|
||||
// The http endpoint to the SRA service, e.g https://sra.0x.org/v2
|
||||
// The http endpoint to the SRA service, e.g https://sra.0x.org/v3
|
||||
httpEndpoint: string;
|
||||
// The interval between polling for each subscription
|
||||
pollingIntervalMs: number;
|
||||
|
@ -25,27 +25,30 @@ describe('MeshOrderProvider', () => {
|
||||
subscription: subscriptionId,
|
||||
result: [
|
||||
{
|
||||
orderHash: '0x96e6eb6174dbf0458686bdae44c9a330d9a9eb563962512a7be545c4ecc13fd4',
|
||||
orderHash: '0xa452cc6e2c7756376f0f2379e7dd81aa9285b26515774d0ad8801a4c243a30a3',
|
||||
signedOrder: {
|
||||
makerAddress: '0x50f84bbee6fb250d6f49e854fa280445369d64d9',
|
||||
chainId: 1337,
|
||||
exchangeAddress: '0x4eacd0af335451709e1e7b570b8ea68edec8bc97',
|
||||
makerAddress: '0x8c5c2671b71bad73d8b6fb7e8ef6fe5ec95ff661',
|
||||
makerAssetData,
|
||||
makerAssetAmount: '4424020538752105500000',
|
||||
makerFeeAssetData: '0x',
|
||||
makerAssetAmount: '19501674723',
|
||||
makerFee: '0',
|
||||
takerAddress: '0x0000000000000000000000000000000000000000',
|
||||
takerAssetData,
|
||||
takerAssetAmount: '1000000000000000061',
|
||||
takerFeeAssetData: '0x',
|
||||
takerAssetAmount: '132880707765170593819',
|
||||
takerFee: '0',
|
||||
senderAddress: '0x0000000000000000000000000000000000000000',
|
||||
exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
|
||||
feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124',
|
||||
expirationTimeSeconds: '1559422407',
|
||||
salt: '1559422141994',
|
||||
feeRecipientAddress: '0x0000000000000000000000000000000000000000',
|
||||
expirationTimeSeconds: '1574687060',
|
||||
salt: '1574686820004',
|
||||
signature:
|
||||
'0x1cf16c2f3a210965b5e17f51b57b869ba4ddda33df92b0017b4d8da9dacd3152b122a73844eaf50ccde29a42950239ba36a525ed7f1698a8a5e1896cf7d651aed203',
|
||||
'0x1b64e67271f10832485356d9ef203b7e2c855067c1253b4e66ee06e85cd46427b157fc4c60f86bd637291f971d1443f65f631b76b887b7f82ebb36499f2f9cf10d03',
|
||||
},
|
||||
kind: 'ADDED',
|
||||
fillableTakerAssetAmount: 1000000000000000061,
|
||||
txHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
endState: 'ADDED',
|
||||
fillableTakerAssetAmount: '132880707765170593819',
|
||||
contractEvents: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -55,7 +58,7 @@ describe('MeshOrderProvider', () => {
|
||||
...{
|
||||
params: {
|
||||
...addedResponse.params,
|
||||
result: [{ ...addedResponse.params.result[0], kind: 'CANCELLED', fillableTakerAssetAmount: 0 }],
|
||||
result: [{ ...addedResponse.params.result[0], endState: 'CANCELLED', fillableTakerAssetAmount: '0' }],
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -152,7 +155,7 @@ describe('MeshOrderProvider', () => {
|
||||
const orders = orderStore.getOrderSetForAssets(makerAssetData, takerAssetData);
|
||||
expect(orders.size()).toBe(1);
|
||||
});
|
||||
test('stores removed orders on a subscription update', async () => {
|
||||
test('removes orders on a subscription update', async () => {
|
||||
const added = JSON.stringify(addedResponse);
|
||||
const removed = JSON.stringify(removedResponse);
|
||||
stubs.push(sinon.stub(WSClient.prototype, 'getOrdersAsync').callsFake(async () => Promise.resolve([])));
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { HttpClient, ordersChannelFactory, OrdersChannelHandler } from '@0x/connect';
|
||||
import { APIOrder, HttpClient, ordersChannelFactory, OrdersChannelHandler } from '@0x/connect';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { SRAWebsocketOrderProvider } from '../../src';
|
||||
import { BaseOrderProvider } from '../../src/order_provider/base_order_provider';
|
||||
import { OrderStore } from '../../src/order_store';
|
||||
import { utils } from '../../src/utils';
|
||||
import { createOrder } from '../utils';
|
||||
|
||||
// tslint:disable-next-line:no-empty
|
||||
@ -56,10 +57,11 @@ describe('SRAWebsocketOrderProvider', () => {
|
||||
expect(stub.callCount).toBe(2);
|
||||
});
|
||||
test('adds orders from the subscription', async () => {
|
||||
const orders: APIOrder[] = [];
|
||||
const stub = sinon.stub(HttpClient.prototype, 'getOrdersAsync').callsFake(async () =>
|
||||
Promise.resolve({
|
||||
records: [],
|
||||
total: 0,
|
||||
records: orders,
|
||||
total: orders.length,
|
||||
perPage: 1,
|
||||
page: 1,
|
||||
}),
|
||||
@ -79,11 +81,12 @@ describe('SRAWebsocketOrderProvider', () => {
|
||||
if (handler) {
|
||||
const channel = '';
|
||||
const subscriptionOpts = {};
|
||||
const orders = [createOrder(makerAssetData, takerAssetData)];
|
||||
orders.push(createOrder(makerAssetData, takerAssetData));
|
||||
handler.onUpdate(channel as any, subscriptionOpts as any, orders);
|
||||
}
|
||||
expect(stub.callCount).toBe(2);
|
||||
expect(wsStub.callCount).toBe(1);
|
||||
await utils.delayAsync(5);
|
||||
const storedOrders = orderStore.getOrderSetForAssets(makerAssetData, takerAssetData);
|
||||
expect(storedOrders.size()).toBe(1);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user