From 871105a48a01c4c1a58cc38d6287eeffd62d2c69 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 10 Feb 2020 17:31:36 -0800 Subject: [PATCH 1/2] Fixed dYdX Bridge Tests --- .../integrations/contracts/test/TestDydxUser.sol | 2 +- .../test/bridges/dydx_bridge_mainnet_test.ts | 14 +++++++------- contracts/integrations/test/mainnet_fork_utils.ts | 2 +- contracts/test-utils/src/web3_wrapper.ts | 6 +++++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/contracts/integrations/contracts/test/TestDydxUser.sol b/contracts/integrations/contracts/test/TestDydxUser.sol index cc0eb3bbb4..f57e85c6d2 100644 --- a/contracts/integrations/contracts/test/TestDydxUser.sol +++ b/contracts/integrations/contracts/test/TestDydxUser.sol @@ -130,7 +130,7 @@ interface IDydx { /// @dev Deploy this contract and call `init` to run the mainnet DydxBridge integration tests. contract TestDydxUser { - address public constant DYDX_BRIDGE_ADDRESS = 0x96DdBa19b69D6EA2549f6a12d005595167414744; + address public constant DYDX_BRIDGE_ADDRESS = 0x55dC8f21D20D4c6ED3C82916A438A413ca68e335; address public constant DYDX_ADDRESS = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; address public constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; uint256 public constant DYDX_DAI_MARKET_ID = 3; diff --git a/contracts/integrations/test/bridges/dydx_bridge_mainnet_test.ts b/contracts/integrations/test/bridges/dydx_bridge_mainnet_test.ts index 62d8a66276..17b117a8f0 100644 --- a/contracts/integrations/test/bridges/dydx_bridge_mainnet_test.ts +++ b/contracts/integrations/test/bridges/dydx_bridge_mainnet_test.ts @@ -14,7 +14,7 @@ import { contractAddresses, dydxAccountOwner } from '../mainnet_fork_utils'; import { dydxEvents } from './abi/dydxEvents'; -blockchainTests.fork.skip('Mainnet dydx bridge tests', env => { +blockchainTests.fork.resets('Mainnet dydx bridge tests', env => { let testContract: DydxBridgeContract; // random account to receive tokens from dydx const receiver = '0x986ccf5234d9cfbb25246f1a5bfa51f4ccfcb308'; @@ -73,7 +73,7 @@ blockchainTests.fork.skip('Mainnet dydx bridge tests', env => { accountOwner: dydxAccountOwner, accountNumber: bridgeData.accountNumbers[action.accountId.toNumber()], market: action.marketId, - update: [[true, scaledAmount]], + update: { deltaWei: { sign: true, value: scaledAmount } }, from: dydxAccountOwner, }); break; @@ -83,7 +83,7 @@ blockchainTests.fork.skip('Mainnet dydx bridge tests', env => { accountOwner: dydxAccountOwner, accountNumber: bridgeData.accountNumbers[action.accountId.toNumber()], market: action.marketId, - update: [[false, scaledAmount]], + update: { deltaWei: { sign: false, value: scaledAmount } }, to: receiver, }); break; @@ -112,10 +112,10 @@ blockchainTests.fork.skip('Mainnet dydx bridge tests', env => { expect(log.args.from, 'from').to.equal(expectedEvent.from); // We only check the first update field because it's the delta balance (amount deposited). // The next field is the new total, which depends on interest rates at the time of execution. - expect(log.args.update[0][0], 'update sign').to.equal(expectedEvent.update[0][0]); - const updateValueHex = log.args.update[0][1]._hex; - const updateValueBn = new BigNumber(updateValueHex, 16); - expect(updateValueBn, 'update value').to.bignumber.equal(expectedEvent.update[0][1]); + expect(log.args.update.deltaWei.sign, 'update sign').to.equal(expectedEvent.update.deltaWei.sign); + expect(log.args.update.deltaWei.value, 'update value').to.bignumber.equal( + expectedEvent.update.deltaWei.value, + ); } }; diff --git a/contracts/integrations/test/mainnet_fork_utils.ts b/contracts/integrations/test/mainnet_fork_utils.ts index 77e1d5af7a..be69c87a63 100644 --- a/contracts/integrations/test/mainnet_fork_utils.ts +++ b/contracts/integrations/test/mainnet_fork_utils.ts @@ -3,7 +3,7 @@ import { ContractWrappers } from '@0x/contract-wrappers'; import { Web3ProviderEngine } from '@0x/dev-utils'; const chainId = 1; -export const dydxAccountOwner = '0xeb58c2caa96f39626dcceb74fdbb7a9a8b54ec18'; +export const dydxAccountOwner = '0xfdac948232c5bfbe24b770326ee4dff7a8dd8484'; export const contractAddresses = getContractAddressesForChainOrThrow(chainId); /** diff --git a/contracts/test-utils/src/web3_wrapper.ts b/contracts/test-utils/src/web3_wrapper.ts index 88b79d3017..1a4eed56e2 100644 --- a/contracts/test-utils/src/web3_wrapper.ts +++ b/contracts/test-utils/src/web3_wrapper.ts @@ -20,7 +20,11 @@ export let providerConfigs: Web3Config = { shouldUseInProcessGanache: true, shouldAllowUnlimitedContractSize: true, hardfork: 'istanbul', - unlocked_accounts: ['0x6cc5f688a315f3dc28a7781717a9a798a59fda7b', '0x55dc8f21d20d4c6ed3c82916a438a413ca68e335'], + unlocked_accounts: [ + '0x6cc5f688a315f3dc28a7781717a9a798a59fda7b', + '0x55dc8f21d20d4c6ed3c82916a438a413ca68e335', + '0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0', // ERC20BridgeProxy + ], }; export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs); From a8c09d0bdb05a28bbfabcf58052355a29493be36 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 10 Feb 2020 17:53:08 -0800 Subject: [PATCH 2/2] Updated contracts-integrations changelog. --- contracts/integrations/CHANGELOG.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contracts/integrations/CHANGELOG.json b/contracts/integrations/CHANGELOG.json index 728bd9feff..4c7cba3f25 100644 --- a/contracts/integrations/CHANGELOG.json +++ b/contracts/integrations/CHANGELOG.json @@ -5,6 +5,10 @@ { "note": "Added ChainlinkStopLimit contract and tests", "pr": 2473 + }, + { + "note": "Fixed the mainnet dYdX Bridge tests.", + "pr": 2479 } ] },