Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Add a regression test for #1550
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Mar 14, 2019
1 parent f57f29e commit e28c6d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export class DependentOrderHashesTracker {
this._zrxTokenAddress = zrxTokenAddress;
}
public getDependentOrderHashesByERC721ByMaker(makerAddress: string, tokenAddress: string): string[] {
let orderHashSets: Array<Set<string>> = [];
if (
this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress] &&
this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress][tokenAddress]
_.isUndefined(this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress]) ||
_.isUndefined(this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress][tokenAddress])
) {
orderHashSets = _.values(
this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress][tokenAddress],
);
return [];
}
const orderHashSets = _.values(
this._orderHashesByERC721AddressByTokenIdByMakerAddress[makerAddress][tokenAddress],
);
const orderHashList = _.reduce(
orderHashSets,
(accumulator, orderHashSet) => [...accumulator, ...orderHashSet],
Expand Down
13 changes: 13 additions & 0 deletions packages/order-watcher/test/order_watcher_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ describe('OrderWatcher', () => {
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('DependentOrderHashesTracker', async () => {
let makerErc721TokenAddress: string;
[makerErc721TokenAddress] = tokenUtils.getDummyERC721TokenAddresses();
it('should handle lookups on unknown addresses', async () => {
// Regression test
// ApprovalForAll events on a token from an untracked address could cause
// nested lookups on undefined object
// #1550
const dependentOrderHashesTracker = (orderWatcher as any)
._dependentOrderHashesTracker as DependentOrderHashesTracker;
dependentOrderHashesTracker.getDependentOrderHashesByERC721ByMaker(takerAddress, makerErc721TokenAddress);
});
});
describe('#removeOrder', async () => {
it('should successfully remove existing order', async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
Expand Down

0 comments on commit e28c6d6

Please sign in to comment.