Commit ab9a5d98 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] duniter devDependency: v1.7.6

parent d2a7aa01
Pipeline #4039 failed with stages
in 29 seconds
......@@ -4,7 +4,8 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"install": "tsc"
"install": "tsc",
"test": "mocha tests/"
},
"dependencies": {
"express": "^4.16.4",
......@@ -22,7 +23,7 @@
"@types/request-promise": "^4.1.42",
"@types/should": "^13.0.0",
"assert": "^1.4.1",
"duniter": "https://git.duniter.org/nodes/typescript/duniter.git",
"duniter": "^1.7.6",
"mocha": "^5.2.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
......
import * as assert from "assert"
import {NewTestingServer, TestingServer} from "duniter/test/integration/tools/toolbox";
import {gvaHttpListen} from "../src/network";
import {Underscore} from "duniter/app/lib/common-libs/underscore";
import {TestUser} from "duniter/test/integration/tools/TestUser";
import {TestGvaClient} from "./test-gva-client";
import * as http from "http";
import {GvaTestUser} from "./test-user";
import {DBBlock} from "duniter/app/lib/db/DBBlock";
import {NewTestingServer, TestingServer} from './test-tools'
export const prepareDuniterServer = async (options:any) => {
......@@ -15,8 +14,17 @@ export const prepareDuniterServer = async (options:any) => {
const s1 = NewTestingServer(Underscore.extend({ pair: catKeyring }, options || {}));
const cat = new TestUser('cat', catKeyring, { server: s1 });
const tac = new TestUser('tac', tacKeyring, { server: s1 });
const cat = {
uid: 'cat',
pub: catKeyring.pub,
sec: catKeyring.sec
}
const tac = {
uid: 'tac',
pub: tacKeyring.pub,
sec: tacKeyring.sec
}
await s1._server.initWithDAL()
......
import {Server} from 'duniter/server'
import {BlockProver} from 'duniter/app/modules/prover/lib/blockProver';
import {ProverDependency} from 'duniter/app/modules/prover';
import * as path from "path"
import * as os from "os"
import {BmaDependency} from 'duniter/app/modules/bma';
export class TestingServer {
constructor(
private port:number,
private server:Server) {
ProverDependency.duniter.methods.hookServer(server)
server.addEndpointsDefinitions(async () => {
return BmaDependency.duniter.methods.getMainEndpoint(server.conf)
})
}
get _server(): Server {
return this.server
}
async commit(options:any = null) {
const proven = await this.generateNext(options)
await this.server.writeBlock(proven, true, true) // The resolution is done manually
const blocksResolved = await this.server.BlockchainService.blockResolution()
if (!blocksResolved) {
throw Error('BLOCK_WASNT_COMMITTED')
}
return blocksResolved
}
async closeCluster() {
const server:Server = this.server
if ((server as any)._utProver) {
const farm = await (server as any)._utProver.getWorker()
await farm.shutDownEngine()
}
}
private generateNext(options:any) {
const server = this.server as any
// Brings a priver to the server
if (!server._utProver) {
server._utProver = new BlockProver(server)
server._utGenerator = ProverDependency.duniter.methods.blockGenerator(server, server._utProver)
}
return server._utGenerator.makeNextBlock(null, null, options)
}
}
const MEMORY_MODE = true;
const CURRENCY_NAME = 'duniter_unit_test_currency';
const HOST = '127.0.0.1';
let PORT = 10000;
export function NewTestingServer(conf:any) {
const host = conf.host || HOST
const port = conf.port || PORT++
const commonConf = {
nobma: false,
bmaWithCrawler: true,
port: port,
ipv4: host,
remoteipv4: host,
currency: conf.currency || CURRENCY_NAME,
httpLogs: true,
forksize: conf.forksize || 3,
};
if (conf.sigQty === undefined) {
conf.sigQty = 1;
}
// Disable UPnP during tests
if (!conf.ws2p) {
conf.ws2p = { upnp: false }
}
Object.keys(commonConf).forEach(k => conf[k] = (commonConf as any)[k])
const server = new Server(
path.resolve(path.join(os.homedir(), '/.config/duniter/' + (conf.homename || 'dev_unit_tests'))),
conf.memory !== undefined ? conf.memory : MEMORY_MODE,
conf);
return new TestingServer(port, server)
}
\ No newline at end of file
......@@ -840,9 +840,9 @@ diff@3.5.0, diff@^3.1.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
"duniter@https://git.duniter.org/nodes/typescript/duniter.git":
version "1.7.1"
resolved "https://git.duniter.org/nodes/typescript/duniter.git#d37aa0609dbaf21c34568633958c2bc17d3dc26a"
duniter@^1.7.6:
version "1.7.6"
resolved "https://registry.yarnpkg.com/duniter/-/duniter-1.7.6.tgz#78dc57e77559be39653cfdef2ebada05619a4c1f"
dependencies:
"@types/leveldown" "^4.0.0"
"@types/levelup" "^3.1.0"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment