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

[fix] CLI test was skept

parent 8f81972b
No related branches found
No related tags found
No related merge requests found
......@@ -206,7 +206,7 @@ export class Synchroniser extends stream.Duplex {
// We use cautious mode if it is asked, or not particulary asked but blockchain has been started
const cautious = (askedCautious === true || localNumber >= 0);
const shuffledPeers = noShufflePeers ? peers : _.shuffle(peers);
const downloader = new P2PDownloader(rCurrent.currency, localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, this.dal, this.slowOption, this.otherDAL);
const downloader = new P2PDownloader(rCurrent.currency, localNumber, to, rCurrent.hash, shuffledPeers, this.watcher, this.logger, hashf, this.dal, this.slowOption, !cautious, this.otherDAL);
downloader.start();
......@@ -678,6 +678,7 @@ class P2PDownloader {
private hashf:any,
private dal:FileDAL,
private slowOption:any,
private nocautious:boolean,
private otherDAL?:FileDAL) {
this.TOO_LONG_TIME_DOWNLOAD = "No answer after " + this.MAX_DELAY_PER_DOWNLOAD + "ms, will retry download later.";
......@@ -756,9 +757,12 @@ class P2PDownloader {
// Chunk is COMPLETE
this.logger.warn("Chunk #%s is COMPLETE from %s", realIndex, [this.handler[realIndex].host, this.handler[realIndex].port].join(':'));
this.chunks[realIndex] = blocks;
// We pre-save blocks only for non-cautious sync
if (this.nocautious) {
await this.dal.blockDAL.insertBatch(blocks.map((b:any) => BlockDTO.fromJSONObject(b)))
this.writtenChunks++
watcher.savedPercent(Math.round(this.writtenChunks / this.numberOfChunksToDownload * 100));
}
this.resultsDeferers[realIndex].resolve(this.chunks[realIndex]);
} else {
this.logger.warn("Chunk #%s DOES NOT CHAIN CORRECTLY from %s", realIndex, [this.handler[realIndex].host, this.handler[realIndex].port].join(':'));
......
......@@ -22,12 +22,11 @@ const toolbox = require('./tools/toolbox');
const duniter = require('../../index');
const merkleh = require('../../app/lib/helpers/merkle');
const hashf = require('../../app/lib/common-libs').hashf
const constants = require('../../app/lib/constants');
const MerkleDTO = require('../../app/lib/dto/MerkleDTO').MerkleDTO
const DB_NAME = "unit_tests";
describe.skip("CLI", function() {
describe("CLI", function() {
let farmOfServers = [], fakeServer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment