(gen, clients, clockRange, attrChoices)
| 417 | * @return {Y.IdMap<T>} |
| 418 | */ |
| 419 | export const createRandomIdMap = (gen, clients, clockRange, attrChoices) => { |
| 420 | const maxOpLen = 5 |
| 421 | const numOfOps = math.ceil((clients * clockRange) / maxOpLen) |
| 422 | const idMap = createIdMap() |
| 423 | for (let i = 0; i < numOfOps; i++) { |
| 424 | const client = prng.uint32(gen, 0, clients - 1) |
| 425 | const clockStart = prng.uint32(gen, 0, clockRange) |
| 426 | const len = prng.uint32(gen, 0, clockRange - clockStart) |
| 427 | const attrs = [prng.oneOf(gen, attrChoices)] |
| 428 | // maybe add another attr |
| 429 | if (prng.bool(gen)) { |
| 430 | const a = prng.oneOf(gen, attrChoices) |
| 431 | if (attrs.find(attr => attr === a) == null) { |
| 432 | attrs.push(a) |
| 433 | } |
| 434 | } |
| 435 | idMap.add(client, clockStart, len, attrs.map(v => Y.createContentAttribute('', v))) |
| 436 | } |
| 437 | t.info(`Created IdMap with ${numOfOps} ranges and ${attrChoices.length} different attributes. Encoded size: ${encodeIdMap(idMap).byteLength}`) |
| 438 | return idMap |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * 1. reconnect and flush all |
no test coverage detected
searching dependent graphs…