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

Fix: broken tests

parent fc77742e
No related branches found
No related tags found
No related merge requests found
...@@ -278,6 +278,16 @@ function Server (dbConf, overrideConf) { ...@@ -278,6 +278,16 @@ function Server (dbConf, overrideConf) {
} }
}); });
this.resetHome = () => co(function *() {
const params = yield paramsP;
const myFS = params.fs;
const rootPath = params.home;
const existsDir = yield myFS.exists(rootPath);
if (existsDir) {
yield myFS.removeTree(rootPath);
}
});
this.resetAll = (done) => { this.resetAll = (done) => {
const files = ['stats', 'cores', 'current', 'conf', directory.UCOIN_DB_NAME, directory.UCOIN_DB_NAME + '.db', directory.WOTB_FILE, 'export.zip', 'import.zip']; const files = ['stats', 'cores', 'current', 'conf', directory.UCOIN_DB_NAME, directory.UCOIN_DB_NAME + '.db', directory.WOTB_FILE, 'export.zip', 'import.zip'];
const dirs = ['blocks', 'ud_history', 'branches', 'certs', 'txs', 'cores', 'sources', 'links', 'ms', 'identities', 'peers', 'indicators', 'leveldb']; const dirs = ['blocks', 'ud_history', 'branches', 'certs', 'txs', 'cores', 'sources', 'links', 'ms', 'identities', 'peers', 'indicators', 'leveldb'];
......
...@@ -49,7 +49,7 @@ describe("Document pool currency", function() { ...@@ -49,7 +49,7 @@ describe("Document pool currency", function() {
it('Identity with wrong currency should be rejected', () => co(function*() { it('Identity with wrong currency should be rejected', () => co(function*() {
const idtyCat1 = yield s1.lookup2identity(cat1.pub); const idtyCat1 = yield s1.lookup2identity(cat1.pub);
console.log(idtyCat1.createIdentity()); idtyCat1.createIdentity();
try { try {
yield s2.postIdentity(idtyCat1); yield s2.postIdentity(idtyCat1);
throw "Identity should not have been accepted, since it has an unknown currency name"; throw "Identity should not have been accepted, since it has an unknown currency name";
......
...@@ -38,7 +38,6 @@ describe("Identities with shared pubkey", function() { ...@@ -38,7 +38,6 @@ describe("Identities with shared pubkey", function() {
})); }));
it('should exit 2 pubkey result', () => s1.expect('/wot/lookup/cat', (res) => { it('should exit 2 pubkey result', () => s1.expect('/wot/lookup/cat', (res) => {
console.log(JSON.stringify(res, null, ' '));
res.results.should.have.length(2); res.results.should.have.length(2);
res.results[0].should.have.property('pubkey').equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); res.results[0].should.have.property('pubkey').equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.results[1].should.have.property('pubkey').equal('2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc'); res.results[1].should.have.property('pubkey').equal('2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc');
......
"use strict"; "use strict";
const _ = require('underscore');
const should = require('should'); const should = require('should');
const fs = require('fs'); const fs = require('fs');
const co = require('co'); const co = require('co');
...@@ -15,17 +16,19 @@ const serverConfig = { ...@@ -15,17 +16,19 @@ const serverConfig = {
} }
}; };
const s0 = toolbox.server(serverConfig); let s1;
const s1 = toolbox.server(serverConfig);
const cat = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 });
const tac = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 });
describe('Import/Export', () => { describe('Import/Export', () => {
before(() => co(function *() { before(() => co(function *() {
yield s0.resetAll(); const s0 = toolbox.server(_.extend({ homename: 'dev_unit_tests1' }, serverConfig));
yield s0.resetHome();
s1 = toolbox.server(_.extend({ homename: 'dev_unit_tests1' }, serverConfig));
const cat = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 });
const tac = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 });
yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections()); yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections());
yield cat.createIdentity(); yield cat.createIdentity();
yield tac.createIdentity(); yield tac.createIdentity();
......
...@@ -38,7 +38,7 @@ module.exports = { ...@@ -38,7 +38,7 @@ module.exports = {
}; };
const server = duniter({ const server = duniter({
memory: conf.memory !== undefined ? conf.memory : MEMORY_MODE, memory: conf.memory !== undefined ? conf.memory : MEMORY_MODE,
name: 'dev_unit_tests' name: conf.homename || 'dev_unit_tests'
}, _.extend(conf, commonConf)); }, _.extend(conf, commonConf));
server.port = port; server.port = port;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment