Skip to content
Snippets Groups Projects
Commit 526291f6 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Tests: sync command

parent 72edae07
No related branches found
No related tags found
No related merge requests found
...@@ -8,14 +8,18 @@ const cli = require('../../app/cli'); ...@@ -8,14 +8,18 @@ const cli = require('../../app/cli');
describe("CLI", function() { describe("CLI", function() {
describe("Initializing", () => {
it('reset data', () => co(function*() { it('reset data', () => co(function*() {
yield execute(['reset', 'data']); yield execute(['reset', 'data']);
const res = yield execute(['export-bc']); const res = yield execute(['export-bc']);
JSON.parse(res).should.have.length(0); JSON.parse(res).should.have.length(0);
})); }));
});
it('sync 10 blocks', () => co(function*() {
yield execute(['reset', 'data']);
yield execute(['sync', 'duniter.org', '8999', '9', '--nointeractive']);
const res = yield execute(['export-bc']);
JSON.parse(res).should.have.length(10);
}));
}); });
/** /**
...@@ -31,7 +35,9 @@ function execute(command) { ...@@ -31,7 +35,9 @@ function execute(command) {
duniter.stdout.on('data', (data) => { duniter.stdout.on('data', (data) => {
res += data.toString('utf8').replace(/\n/, ''); res += data.toString('utf8').replace(/\n/, '');
}); });
duniter.stderr.on('data', (err) => reject(err.toString('utf8'))); duniter.stderr.on('data', (err) => {
console.log(err.toString('utf8').replace(/\n/, ''));
});
duniter.on('close', (code) => code ? reject(code) : resolve(res) ); duniter.on('close', (code) => code ? reject(code) : resolve(res) );
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment