Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.mockLibp2pNode = () => {
const peerInfo = new PeerInfo(PeerId.createFromHexString('122019318b6e5e0cf93a2314bf01269a2cc23cd3dcd452d742cdb9379d8646f6e4a9'))
return Object.assign(new EventEmitter(), {
peerInfo: peerInfo,
handle () {},
unhandle () {},
contentRouting: {
provide: (cid, callback) => callback(),
findProviders: (cid, timeout, callback) => callback(null, [])
},
on () {},
dial (peer, protocol, callback) {
setImmediate(() => callback())
},
swarm: {
muxedConns: {},
setMaxListeners () {}
end = parseInt(parts[1]);
} else {
end = parseInt(options.validators);
}
for (let i = start; i < end; i++) {
const validatorPath = `./validators/validator-db-${i}`;
if(fs.existsSync(validatorPath)) {
rmDir(validatorPath);
}
}
}
}
let peerId;
if (options["peerId"]) {
peerId = PeerId.createFromHexString(options["peerId"]);
} else if (options["peerIdFile"]) {
peerId = loadPeerId(options["peerId"]);
} else {
peerId = createPeerId();
}
const libp2p = await createNodeJsLibp2p(peerId, conf.network);
const config = options.preset === "minimal" ? minimalConfig : mainnetConfig;
const tree = ProgressiveMerkleTree.empty(DEPOSIT_CONTRACT_TREE_DEPTH, new MerkleTreeSerialization(config));
let state: BeaconState;
if (options.genesisState) {
state = quickStartOptionToState(config, tree, options.genesisState);
} else if (options.genesisTime && options.validatorCount) {
logger.info(`Starting node with genesisTime ${new Date(parseInt(options.genesisTime)*1000)} and \
${options.validatorCount} validators.`);
state = quickStartState(config, tree, parseInt(options.genesisTime), parseInt(options.validatorCount));
} else {