From 285fb3deadd0413bf993557575a3f96a840f0e10 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 17 Dec 2018 18:26:03 -0800 Subject: Progress --- contracts/protocol/test/asset_proxy/proxies.ts | 24 ++++++++++++++++++++++++ contracts/protocol/test/exchange/core.ts | 24 ++++++++++++------------ contracts/protocol/test/utils/erc721_wrapper.ts | 4 ++++ 3 files changed, 40 insertions(+), 12 deletions(-) (limited to 'contracts/protocol') diff --git a/contracts/protocol/test/asset_proxy/proxies.ts b/contracts/protocol/test/asset_proxy/proxies.ts index bbb44f402..b2e7f5afb 100644 --- a/contracts/protocol/test/asset_proxy/proxies.ts +++ b/contracts/protocol/test/asset_proxy/proxies.ts @@ -78,6 +78,7 @@ describe('Asset Transfer Proxies', () => { await blockchainLifecycle.revertAsync(); }); before(async () => { + console.log('1'); const accounts = await web3Wrapper.getAvailableAddressesAsync(); const usedAddresses = ([owner, notAuthorized, authorized, fromAddress, toAddress] = _.slice(accounts, 0, 5)); @@ -93,6 +94,7 @@ describe('Asset Transfer Proxies', () => { txDefaults, ); + console.log('2'); // Configure ERC20Proxy await web3Wrapper.awaitTransactionSuccessAsync( await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(authorized, { @@ -100,6 +102,7 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('3'); await web3Wrapper.awaitTransactionSuccessAsync( await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { from: owner, @@ -107,6 +110,8 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('4'); + // Configure ERC721Proxy await web3Wrapper.awaitTransactionSuccessAsync( await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(authorized, { @@ -114,6 +119,8 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); + + console.log('5'); await web3Wrapper.awaitTransactionSuccessAsync( await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { from: owner, @@ -121,6 +128,8 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('6'); + // Configure MultiAssetProxy await web3Wrapper.awaitTransactionSuccessAsync( await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(authorized, { @@ -128,12 +137,16 @@ describe('Asset Transfer Proxies', () => { }), constants.AWAIT_TRANSACTION_MINED_MS, ); + + console.log('7'); await web3Wrapper.awaitTransactionSuccessAsync( await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); + + console.log('8'); await web3Wrapper.awaitTransactionSuccessAsync( await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, { from: owner, @@ -141,6 +154,8 @@ describe('Asset Transfer Proxies', () => { constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('9'); + // Deploy and configure ERC20 tokens const numDummyErc20ToDeploy = 2; [erc20TokenA, erc20TokenB] = await erc20Wrapper.deployDummyTokensAsync( @@ -166,11 +181,14 @@ describe('Asset Transfer Proxies', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); + console.log('10'); + await erc20Wrapper.setBalancesAndAllowancesAsync(); await web3Wrapper.awaitTransactionSuccessAsync( await noReturnErc20Token.setBalance.sendTransactionAsync(fromAddress, constants.INITIAL_ERC20_BALANCE), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('11'); await web3Wrapper.awaitTransactionSuccessAsync( await noReturnErc20Token.approve.sendTransactionAsync( erc20Proxy.address, @@ -179,6 +197,7 @@ describe('Asset Transfer Proxies', () => { ), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('12'); await web3Wrapper.awaitTransactionSuccessAsync( await multipleReturnErc20Token.setBalance.sendTransactionAsync( fromAddress, @@ -186,6 +205,7 @@ describe('Asset Transfer Proxies', () => { ), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('13'); await web3Wrapper.awaitTransactionSuccessAsync( await multipleReturnErc20Token.approve.sendTransactionAsync( erc20Proxy.address, @@ -194,6 +214,7 @@ describe('Asset Transfer Proxies', () => { ), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('14'); // Deploy and configure ERC721 tokens and receiver [erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync(); @@ -202,9 +223,12 @@ describe('Asset Transfer Proxies', () => { provider, txDefaults, ); + console.log('15'); await erc721Wrapper.setBalancesAndAllowancesAsync(); + console.log('16'); const erc721Balances = await erc721Wrapper.getBalancesAsync(); + console.log('17'); erc721AFromTokenId = erc721Balances[fromAddress][erc721TokenA.address][0]; erc721BFromTokenId = erc721Balances[fromAddress][erc721TokenB.address][0]; }); diff --git a/contracts/protocol/test/exchange/core.ts b/contracts/protocol/test/exchange/core.ts index 700643b79..6688f0fad 100644 --- a/contracts/protocol/test/exchange/core.ts +++ b/contracts/protocol/test/exchange/core.ts @@ -1035,18 +1035,18 @@ describe('Exchange core', () => { }); }); - describe('getOrderInfo', () => { + describe.only('getOrderInfo', () => { beforeEach(async () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); - it('should return the correct orderInfo for an unfilled valid order', async () => { + it.only('should return the correct orderInfo for an unfilled valid order', async () => { const orderInfo = await exchangeWrapper.getOrderInfoAsync(signedOrder); const expectedOrderHash = orderHashUtils.getOrderHashHex(signedOrder); const expectedTakerAssetFilledAmount = new BigNumber(0); const expectedOrderStatus = OrderStatus.Fillable; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for a fully filled order', async () => { await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress); @@ -1056,7 +1056,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.FullyFilled; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for a partially filled order', async () => { const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -1067,7 +1067,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.Fillable; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for a cancelled and unfilled order', async () => { await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress); @@ -1077,7 +1077,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.Cancelled; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for a cancelled and partially filled order', async () => { const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -1089,7 +1089,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.Cancelled; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for an expired and unfilled order', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); @@ -1101,7 +1101,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.Expired; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for an expired and partially filled order', async () => { const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -1115,7 +1115,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.Expired; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for an expired and fully filled order', async () => { await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress); @@ -1129,7 +1129,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.FullyFilled; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for an order with a makerAssetAmount of 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(0) }); @@ -1139,7 +1139,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.InvalidMakerAssetAmount; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); it('should return the correct orderInfo for an order with a takerAssetAmount of 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ takerAssetAmount: new BigNumber(0) }); @@ -1149,7 +1149,7 @@ describe('Exchange core', () => { const expectedOrderStatus = OrderStatus.InvalidTakerAssetAmount; expect(orderInfo.orderHash).to.be.equal(expectedOrderHash); expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount); - expect(orderInfo.orderStatus).to.equal(expectedOrderStatus); + expect(orderInfo.orderStatus).to.be.bignumber.equal(expectedOrderStatus); }); }); }); diff --git a/contracts/protocol/test/utils/erc721_wrapper.ts b/contracts/protocol/test/utils/erc721_wrapper.ts index 1f658ce86..138fccf6f 100644 --- a/contracts/protocol/test/utils/erc721_wrapper.ts +++ b/contracts/protocol/test/utils/erc721_wrapper.ts @@ -102,12 +102,15 @@ export class ERC721Wrapper { public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId); + console.log('a'); + console.log(to, ':', tokenId, ':', tokenOwner); await this._web3Wrapper.awaitTransactionSuccessAsync( await tokenContract.approve.sendTransactionAsync(to, tokenId, { from: tokenOwner, }), constants.AWAIT_TRANSACTION_MINED_MS, ); + console.log('b'); } public async transferFromAsync( tokenAddress: string, @@ -144,6 +147,7 @@ export class ERC721Wrapper { public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise { const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const owner = await tokenContract.ownerOf.callAsync(tokenId); + console.log(`OWNER OF = ${owner}`); return owner; } public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise { -- cgit v1.2.3