aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-16 20:30:48 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-16 20:30:48 +0800
commitc5ba52910a3716e0e9db65b16e86a129370cdae3 (patch)
tree66966e94fae1b7e755918ebb7d562d16d833c9f6
parent994ccd669455f8736ea1f9c0840ee824f409001a (diff)
downloaddexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar.gz
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar.bz2
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar.lz
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar.xz
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.tar.zst
dexon-sol-tools-c5ba52910a3716e0e9db65b16e86a129370cdae3.zip
Add ERC721 tests to order watcher
-rw-r--r--packages/order-watcher/test/expiration_watcher_test.ts4
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts64
2 files changed, 64 insertions, 4 deletions
diff --git a/packages/order-watcher/test/expiration_watcher_test.ts b/packages/order-watcher/test/expiration_watcher_test.ts
index 3c92ddb63..f765e8278 100644
--- a/packages/order-watcher/test/expiration_watcher_test.ts
+++ b/packages/order-watcher/test/expiration_watcher_test.ts
@@ -43,7 +43,6 @@ describe('ExpirationWatcher', () => {
let expirationWatcher: ExpirationWatcher;
before(async () => {
await blockchainLifecycle.startAsync();
- const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
fillScenarios = new FillScenarios(
@@ -51,7 +50,8 @@ describe('ExpirationWatcher', () => {
userAddresses,
zrxTokenAddress,
exchangeContractAddress,
- erc20ProxyAddress,
+ contractWrappers.erc20Proxy.getContractAddress(),
+ contractWrappers.erc721Proxy.getContractAddress(),
);
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
const [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 6339505ce..a47dfcd77 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -57,7 +57,6 @@ describe('OrderWatcher', () => {
const fillableAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5), decimals);
before(async () => {
await blockchainLifecycle.startAsync();
- const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
@@ -66,7 +65,8 @@ describe('OrderWatcher', () => {
userAddresses,
zrxTokenAddress,
exchangeContractAddress,
- erc20ProxyAddress,
+ contractWrappers.erc20Proxy.getContractAddress(),
+ contractWrappers.erc721Proxy.getContractAddress(),
);
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
@@ -534,5 +534,65 @@ describe('OrderWatcher', () => {
);
})().catch(done);
});
+ describe('erc721', () => {
+ let makerErc721AssetData: string;
+ let makerErc721TokenAddress: string;
+ const tokenId = new BigNumber(42);
+ [makerErc721TokenAddress] = tokenUtils.getDummyERC721TokenAddresses();
+ makerErc721AssetData = assetProxyUtils.encodeERC721AssetData(makerErc721TokenAddress, tokenId);
+ const fillableErc721Amount = new BigNumber(1);
+ it('should emit orderStateInvalid when makerAddress allowance for all set to 0 for watched order', (done: DoneCallback) => {
+ (async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerErc721AssetData,
+ takerAssetData,
+ makerAddress,
+ takerAddress,
+ fillableErc721Amount,
+ );
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
+ orderWatcher.addOrder(signedOrder);
+ const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
+ expect(orderState.isValid).to.be.false();
+ const invalidOrderState = orderState as OrderStateInvalid;
+ expect(invalidOrderState.orderHash).to.be.equal(orderHash);
+ expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerAllowance);
+ });
+ orderWatcher.subscribe(callback);
+ const isApproved = false;
+ await contractWrappers.erc721Token.setProxyApprovalForAllAsync(
+ makerErc721TokenAddress,
+ makerAddress,
+ isApproved,
+ );
+ })().catch(done);
+ });
+ it('should emit orderStateInvalid when makerAddress moves NFT backing watched order', (done: DoneCallback) => {
+ (async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerErc721AssetData,
+ takerAssetData,
+ makerAddress,
+ takerAddress,
+ fillableErc721Amount,
+ );
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
+ orderWatcher.addOrder(signedOrder);
+ const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
+ expect(orderState.isValid).to.be.false();
+ const invalidOrderState = orderState as OrderStateInvalid;
+ expect(invalidOrderState.orderHash).to.be.equal(orderHash);
+ expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerBalance);
+ });
+ orderWatcher.subscribe(callback);
+ await contractWrappers.erc721Token.transferFromAsync(
+ makerErc721TokenAddress,
+ coinbase,
+ makerAddress,
+ tokenId,
+ );
+ })().catch(done);
+ });
+ });
});
}); // tslint:disable:max-file-line-count