aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 00:46:58 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 00:46:58 +0800
commitf20b496dca2dceb4f53ae20660798f8b8148a265 (patch)
treea26b8d3c4cfaf7e8d2bb5f65d53b8a056b08985c
parentcca17f70b83d42205b58af9a430fa9c98334bb47 (diff)
downloaddexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar.gz
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar.bz2
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar.lz
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar.xz
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.tar.zst
dexon-sol-tools-f20b496dca2dceb4f53ae20660798f8b8148a265.zip
Add a test for ERC721 Allowance
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts38
1 files changed, 37 insertions, 1 deletions
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 8169f61b4..cd2b7bbfe 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -541,6 +541,31 @@ describe('OrderWatcher', () => {
[makerErc721TokenAddress] = tokenUtils.getDummyERC721TokenAddresses();
makerErc721AssetData = assetProxyUtils.encodeERC721AssetData(makerErc721TokenAddress, tokenId);
const fillableErc721Amount = new BigNumber(1);
+ it('should emit orderStateInvalid when maker allowance set to 0 for watched order', (done: DoneCallback) => {
+ (async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerErc721AssetData,
+ takerAssetData,
+ makerAddress,
+ takerAddress,
+ fillableErc721Amount,
+ );
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
+ await orderWatcher.addOrderAsync(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);
+ await contractWrappers.erc721Token.setApprovalAsync(
+ makerErc721TokenAddress,
+ constants.NULL_ADDRESS,
+ tokenId,
+ );
+ })().catch(done);
+ });
it('should emit orderStateInvalid when maker allowance for all set to 0 for watched order', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
@@ -550,6 +575,17 @@ describe('OrderWatcher', () => {
takerAddress,
fillableErc721Amount,
);
+ await contractWrappers.erc721Token.setApprovalAsync(
+ makerErc721TokenAddress,
+ constants.NULL_ADDRESS,
+ tokenId,
+ );
+ let isApproved = true;
+ await contractWrappers.erc721Token.setProxyApprovalForAllAsync(
+ makerErc721TokenAddress,
+ makerAddress,
+ isApproved,
+ );
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
await orderWatcher.addOrderAsync(signedOrder);
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
@@ -559,7 +595,7 @@ describe('OrderWatcher', () => {
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerAllowance);
});
orderWatcher.subscribe(callback);
- const isApproved = false;
+ isApproved = false;
await contractWrappers.erc721Token.setProxyApprovalForAllAsync(
makerErc721TokenAddress,
makerAddress,