Skip to content

Commit c80145a

Browse files
authored
feat(origin-ui): filter, search claimed certificates, bulk claim in inbox (#44)
- add filter and search to claimed certificates - add bulk claiming certificates - allow strictly typed blockchain configuration across a package - give more time for matcher tests to complete to avoid breaking tests on master - remove package-lock.json from market and update gitignore
1 parent 2dd77ac commit c80145a

File tree

20 files changed

+407
-6835
lines changed

20 files changed

+407
-6835
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist
44
dist-shakeable
55
db.json
66
.vscode
7-
*.log
7+
*.log
8+
package-lock.json

packages/market-matcher/src/test/Matcher.test.ts

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,31 @@ const PROVIDER_URL = 'http://localhost:8545';
1717
const BACKEND_URL = 'http://localhost:3030';
1818
const deployKey = 'd9066ff9f753a1898709b568119055660a77d9aae4d7a4ad677b8fb3d2a571e5';
1919

20-
describe('Test StrategyBasedMatcher', async () => {
20+
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
21+
22+
async function waitForConditionAndAssert(
23+
conditionCheckFunction: () => Promise<boolean> | boolean,
24+
assertFunction: () => Promise<void> | void,
25+
interval: number,
26+
timeout: number
27+
): Promise<void> {
28+
let timePassed = 0;
29+
30+
while (timePassed < timeout) {
31+
if (await conditionCheckFunction()) {
32+
await assertFunction();
33+
34+
return;
35+
}
36+
37+
await sleep(interval);
38+
timePassed += interval;
39+
}
40+
41+
await assertFunction();
42+
}
43+
44+
describe.only('Test StrategyBasedMatcher', async () => {
2145
const web3 = new Web3(PROVIDER_URL);
2246

2347
const privateKeyDeployment = deployKey.startsWith('0x') ? deployKey : `0x${deployKey}`;
@@ -61,8 +85,6 @@ describe('Test StrategyBasedMatcher', async () => {
6185
}
6286
};
6387

64-
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
65-
6688
describe('Setup', () => {
6789
it('should deploy user-registry contracts', async () => {
6890
const userContracts = await migrateUserRegistryContracts(web3, privateKeyDeployment);
@@ -360,11 +382,20 @@ describe('Test StrategyBasedMatcher', async () => {
360382
privateKey: privateKeyDeployment
361383
};
362384

363-
await sleep(10000);
385+
await waitForConditionAndAssert(
386+
async () => {
387+
const certificate = await new Certificate.Entity('0', conf).sync();
364388

365-
const certificate = await new Certificate.Entity('0', conf).sync();
366-
assert.equal(certificate.owner, accountTrader);
367-
}).timeout(11000);
389+
return certificate.owner === accountTrader;
390+
},
391+
async () => {
392+
const certificate = await new Certificate.Entity('0', conf).sync();
393+
assert.equal(certificate.owner, accountTrader);
394+
},
395+
1000,
396+
20000
397+
);
398+
}).timeout(21000);
368399
});
369400

370401
describe('Agreement -> Certificate matching tests', () => {
@@ -541,10 +572,20 @@ describe('Test StrategyBasedMatcher', async () => {
541572
it('demand should be matched with existing certificate', async () => {
542573
const demand = await new Demand.Entity('1', conf).sync();
543574

544-
await sleep(10000);
575+
await waitForConditionAndAssert(
576+
async () => {
577+
const certificate = await new Certificate.Entity(certificateId, conf).sync();
545578

546-
const certificate = await new Certificate.Entity(certificateId, conf).sync();
547-
assert.equal(certificate.owner, demand.demandOwner);
548-
}).timeout(15000);
579+
return certificate.owner === demand.demandOwner;
580+
},
581+
async () => {
582+
const certificate = await new Certificate.Entity(certificateId, conf).sync();
583+
584+
assert.equal(certificate.owner, demand.demandOwner);
585+
},
586+
1000,
587+
20000
588+
);
589+
}).timeout(30000);
549590
});
550591
});

packages/market/.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
.DS_Store
2-
node_modules
3-
dist
41
schemas
5-
build
6-
db.json
2+
build

0 commit comments

Comments
 (0)