Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
plugins[newPlugin.PLUGIN_NAME] = plugin;
return send(newPlugin.PLUGIN_NAME, 'MASTER', { action: 'init', payload: conf });
};
const unloadPlugin = (plugin) => {
plugins[plugin.PLUGIN_NAME].cp.kill('SIGINT');
plugins[plugin.PLUGIN_NAME] = null;
jobs = new Map();
currentJobId = 0;
}
const db = new Database(conf.databaseURL);
const FORK_BLOCK_NUMBER = 30896500;
const SSC_STORE_QTY = '0.001';
// tokens
describe('Tokens smart contract', function () {
this.timeout(10000);
beforeEach((done) => {
new Promise(async (resolve) => {
try {
await db.dropDatabase(conf.databaseName);
} catch (error) {
}
plugin.cp.stdout.on('data', data => console.log(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
plugin.cp.stderr.on('data', data => console.error(`[${newPlugin.PLUGIN_NAME}]`, data.toString()));
plugins[newPlugin.PLUGIN_NAME] = plugin;
return send(newPlugin.PLUGIN_NAME, 'MASTER', { action: 'init', payload: conf });
};
const unloadPlugin = (plugin) => {
plugins[plugin.PLUGIN_NAME].cp.kill('SIGINT');
plugins[plugin.PLUGIN_NAME] = null;
jobs = new Map();
currentJobId = 0;
}
const db = new Database(conf.databaseURL);
const FORK_BLOCK_NUMBER = 30896500;
// smart tokens
describe('smart tokens', function () {
this.timeout(30000);
beforeEach((done) => {
new Promise(async (resolve) => {
try {
await db.dropDatabase(conf.databaseName);
} catch (error) {
}
resolve();
AfterAll(async function () {
// Delete almost all Arango dbs.
const systemDb = new Database();
systemDb.useBasicAuth(config.database.username, config.database.password);
const listOfDatabases = await systemDb.listDatabases();
const that = this;
listOfDatabases.forEach(async function (databaseItem) {
if (databaseItem !== '_system' && databaseItem !== 'origintrail' && databaseItem !== 'origintrail-develop' && databaseItem !== 'origintrail-staging' && databaseItem !== 'origintrail-stable') {
try {
await systemDb.dropDatabase(databaseItem);
} catch (error) {
that.logger.log(`Oops, failed to delete database: ${databaseItem}`);
that.logger.log(error);
}
}
});
async function resetArangoDb(database) {
console.info(`Setting up graph database '${database.database}'...`);
const systemDb = new Database();
systemDb.useBasicAuth(database.username, database.password);
// Drop test database if exist.
const listOfDatabases = await systemDb.listDatabases();
if (listOfDatabases.includes(database.database)) {
await
systemDb.dropDatabase(database.database);
}
await
systemDb.createDatabase(
database.database,
[{ username: database.username, passwd: database.password, active: true }],
);
}
export function getTempDatabase(): Database {
const db = new Database({
url: DATABASE_URL
});
db.useDatabase(DATABASE_NAME);
return db;
}
constructor(username, password, database, host, port, log) {
this.log = log;
this.db = new Database(`http://${host}:${port}`);
this.db.useDatabase(database);
this.db.useBasicAuth(username, password);
}
return new Promise((resolve, reject) => {
switch (config.database.provider) {
case 'arangodb': {
const systemDb = new Database();
systemDb.useBasicAuth(config.database.username, config.database.password);
systemDb.listDatabases().then((result) => {
let databaseAlreadyExists = false;
for (let i = 0; i < result.length; i += 1) {
if (result[i].toString() === config.database.database) {
databaseAlreadyExists = true;
}
}
if (!databaseAlreadyExists) {
systemDb.createDatabase(
config.database.database,
[{
username: config.database.username,
passwd: config.database.password,
active: true,
}],
constructor(h: Http) {
this.connector = new arango.Database({ url: StoreUtils.host });
this.connector.useBasicAuth(StoreUtils.username, StoreUtils.password);
this.http = h;
this.headers = new Headers();
this.headers.append("Authorization", "Basic " + btoa(StoreUtils.username + ":" + StoreUtils.password));
}
useFactory: async (): Promise => {
const db = new Database();
db.useDatabase('');
db.useBasicAuth('');
return db;
},
},