2017-06-02 07:09:49 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-11-06 15:13:30 +00:00
|
|
|
// Check that spawn child doesn't create duplicated entries
|
|
|
|
require('../common');
|
2019-01-15 18:31:12 +00:00
|
|
|
const Countdown = require('../common/countdown');
|
2017-06-02 07:09:49 +00:00
|
|
|
const REPETITIONS = 2;
|
|
|
|
const assert = require('assert');
|
2017-11-06 15:13:30 +00:00
|
|
|
const fixtures = require('../common/fixtures');
|
2019-01-15 18:31:12 +00:00
|
|
|
const { spawn } = require('child_process');
|
2017-11-06 15:13:30 +00:00
|
|
|
const targetScript = fixtures.path('guess-hash-seed.js');
|
2017-06-02 07:09:49 +00:00
|
|
|
const seeds = [];
|
|
|
|
|
2019-01-15 18:31:12 +00:00
|
|
|
const requiredCallback = () => {
|
|
|
|
console.log(`Seeds: ${seeds}`);
|
|
|
|
assert.strictEqual(new Set(seeds).size, seeds.length);
|
|
|
|
assert.strictEqual(seeds.length, REPETITIONS);
|
|
|
|
};
|
|
|
|
|
|
|
|
const countdown = new Countdown(REPETITIONS, requiredCallback);
|
|
|
|
|
2017-06-02 07:09:49 +00:00
|
|
|
for (let i = 0; i < REPETITIONS; ++i) {
|
2019-01-15 18:31:12 +00:00
|
|
|
let result = '';
|
|
|
|
const subprocess = spawn(process.execPath, [targetScript]);
|
|
|
|
subprocess.stdout.setEncoding('utf8');
|
|
|
|
subprocess.stdout.on('data', (data) => { result += data; });
|
2017-06-02 07:09:49 +00:00
|
|
|
|
2019-01-15 18:31:12 +00:00
|
|
|
subprocess.on('exit', () => {
|
|
|
|
seeds.push(result.trim());
|
|
|
|
countdown.dec();
|
|
|
|
});
|
|
|
|
}
|