Skip to content

Commit

Permalink
init stresstest cli #53
Browse files Browse the repository at this point in the history
  • Loading branch information
turinglabsorg committed Jul 15, 2022
1 parent cf0b609 commit 66b1d50
Show file tree
Hide file tree
Showing 6 changed files with 2,590 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stress-cli/.env.rinkeby
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONTRACT_ADDRESS=0xBD04e6756A5E3B57373195D519684d4911625ac0
WEB3_PROVIDER=https://rinkeby.infura.io/v3/PROJECT_ID
4 changes: 4 additions & 0 deletions stress-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
pldr-provider-*
bootstrap_nodes
.env
30 changes: 30 additions & 0 deletions stress-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "pldr-provider",
"version": "0.0.1",
"description": "",
"main": "src/stress.js",
"bin": "src/stress.js",
"scripts": {
"test:identity": "node src/stress.js --debug --name=stressdev --port=8000 getidentity",
"test:peers": "node src/stress.js --debug --name=stressdev --port=8000 ipfs swarm peers",
"test:pins": "node src/stress.js --debug --name=stressdev --port=8000 ipfs pin ls",
"compile": "pkg . --out-path bin",
"start": "./bin/pldr-provider-linux --debug --name=stress --port=8000"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"axios": "^0.24.0",
"body-parser": "^1.19.0",
"dotenv": "^10.0.0",
"ethers": "^5.6.2",
"express": "^4.17.1",
"minimist": "^1.2.6",
"public-ip": "^4.0.4"
},
"devDependencies": {
"nodemon": "^2.0.14",
"pkg": "^5.6.0"
}
}
12 changes: 12 additions & 0 deletions stress-cli/src/libs/fn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const axios = require('axios');

const ipfs = (node, ...args) => {
node.runIpfsNativeCommand(args.join(' '))
}

const getidentity = (node) => {
console.log(node.returnNodeIdentity())
}


module.exports = { getidentity, ipfs}
49 changes: 49 additions & 0 deletions stress-cli/src/stress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const argv = require('minimist')(process.argv.slice(2));
const cwd = process.cwd()
let homedir = require('os').homedir()
const PldrNode = require('../../shared/pldr')
const commands = require('./libs/fn')
const debug = argv.debug !== undefined ? argv.debug : false
const name = argv.name !== undefined ? argv.name : "pldr-stress"
const port = argv.port !== undefined ? argv.port : 8000
const daemon = argv.daemon !== undefined ? true : false
if (argv.docker !== undefined) {
homedir = './'
}
// Print initial conditions if debug is active
if (debug) {
console.log('--')
console.log('DEBUG MODE')
console.log('--')
console.log('Working dir is:', cwd)
console.log('Homedir is:', homedir)
console.log('Node name is:', name)
}
// Init node folder and configs
const node = new PldrNode(name, port, daemon)
if (daemon) {
console.log('Loaded identity:', node.returnNodeIdentity())
}
// Detect commands
async function main() {
if (argv._ !== undefined && argv._[0] !== undefined) {
if (commands[argv._[0]] !== undefined) {
if (debug) {
console.log('Running command: ' + argv._.join(' '))
console.log('--')
}
commands[argv._[0]](node, ...argv._)
} else {
console.log('Command not recognized')
}
} else {
console.log('No command found')
}
}
if (!daemon) {
main()
} else {
setTimeout(function () {
commands.daemon(node)
}, 5000)
}
Loading

0 comments on commit 66b1d50

Please sign in to comment.