diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts index c75e894da45b33a3265ad91bcc897b6d2fd81fdd..828b6a1357c59f17cb5107be4c64172c5e5d6cb0 100644 --- a/app/lib/indexer.ts +++ b/app/lib/indexer.ts @@ -867,7 +867,7 @@ export class Indexer { mindex.map((ENTRY: MindexEntry) => { ENTRY.isBeingRevoked = !!ENTRY.revoked_on; }); -yarn + // BR_G107 if (HEAD.number > 0) { await Promise.all( @@ -937,8 +937,10 @@ yarn if (HEAD.version < 12) { conf.stepMax = 7; } - const oneIsOutdistanced = await checkPeopleAreNotOudistanced( - Underscore.filter(mindex, (entry: MindexEntry) => !entry.revoked_on).map((entry: MindexEntry) => entry.pub), + const oneIsOutdistanced = await checkPeopleAreNotOudistanced( + Underscore.filter(mindex, (entry: MindexEntry) => !entry.revoked_on).map( + (entry: MindexEntry) => entry.pub + ), cindex.reduce((newLinks, c: CindexEntry) => { newLinks[c.receiver] = newLinks[c.receiver] || []; newLinks[c.receiver].push(c.issuer); @@ -983,20 +985,27 @@ yarn ); // BR_G27 - await Promise.all(mindex.map(async (ENTRY: MindexEntry) => { - if (ENTRY.type == 'JOIN' || ENTRY.type == 'ACTIVE') { - const existing = (await dal.cindexDAL.findByReceiverAndExpiredOn(ENTRY.pub, 0)).map(value => value.issuer) - const pending = Underscore.filter(cindex, (c:CindexEntry) => c.receiver == ENTRY.pub && c.expired_on == 0).map(value => value.issuer) - const uniqIssuers = Underscore.uniq(existing.concat(pending)) - if (HEAD.version >= 12) { - ENTRY.enoughCerts = count(uniqIssuers) >= conf.sigQty; + await Promise.all( + mindex.map(async (ENTRY: MindexEntry) => { + if (ENTRY.type == "JOIN" || ENTRY.type == "ACTIVE") { + const existing = ( + await dal.cindexDAL.findByReceiverAndExpiredOn(ENTRY.pub, 0) + ).map((value) => value.issuer); + const pending = Underscore.filter( + cindex, + (c: CindexEntry) => c.receiver == ENTRY.pub && c.expired_on == 0 + ).map((value) => value.issuer); + const uniqIssuers = Underscore.uniq(existing.concat(pending)); + if (HEAD.version >= 12) { + ENTRY.enoughCerts = count(uniqIssuers) >= conf.sigQty; + } else { + ENTRY.enoughCerts = count(uniqIssuers) >= 1; + } } else { - ENTRY.enoughCerts = count(uniqIssuers) >= 1; + ENTRY.enoughCerts = true; } - } else { - ENTRY.enoughCerts = true; - } - })) + }) + ); // BR_G28 await Promise.all( diff --git a/test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts b/test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts index e89ba363726d1f0e346eaa82ccbd699c4a65db51..df09b97906c4b86e9e54b8bd6474c0247408bcec 100644 --- a/test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts +++ b/test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts @@ -15,7 +15,7 @@ import {assertEqual, writeBasicTestWithConfAnd2Users} from "../tools/test-framew import {CommonConstants} from "../../../app/lib/common-libs/constants" import {assertThrows} from "../../unit-tools" -const currentVersion = CommonConstants.BLOCK_GENESIS_VERSION +const genesisVersion = CommonConstants.BLOCK_GENESIS_VERSION describe('A member coming back with less than `sigQty` valid certs total', () => writeBasicTestWithConfAnd2Users({ sigQty: 2, @@ -29,7 +29,7 @@ describe('A member coming back with less than `sigQty` valid certs total', () => const now = 1500000000 test('(t = 0) should init with a 3 members WoT with bidirectionnal certs', async (s1, cat, tac, toc) => { - CommonConstants.BLOCK_GENESIS_VERSION = 11 + CommonConstants.BLOCK_GENESIS_VERSION = 12 await cat.createIdentity() await tac.createIdentity() await toc.createIdentity() @@ -100,7 +100,7 @@ describe('A member coming back with less than `sigQty` valid certs total', () => }) after(() => { - CommonConstants.BLOCK_GENESIS_VERSION = currentVersion + CommonConstants.BLOCK_GENESIS_VERSION = genesisVersion }) }))