Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function() {
/** After each test clean up data that was injected into the database */
event.dispatcher.on(event.test.after, async (test) => {
try{
// Remove any and all data that was injected into the DB
// after each test
await Apis.cleanUp();
} catch (err) {
// eslint-disable-next-line angular/log
console.log(`The following error was thrown while cleaning up injected data: ${err}`);
}
});
};
const output = require('codeceptjs').output;
const utils = require('../../utils');
const I = actor();
const count = Math.ceil(utils.TRS_POOL_LIMIT / 13); // T:2, SPP: 1, D 2, V: 2, UV: 2, M: 2, Dapp: 2 = 13 types of transactions
let all_trxs = {};
const accounts = utils.createAccounts(count);
const accounts_with_spp = utils.createAccounts(count);
const getAllTransactions = () => {
const transactions = Object.keys(all_trxs).map(transaction_type => {
const trxs = all_trxs[transaction_type];
if (!transaction_type.match('_signatures')) {
return trxs;
}
return [];
const event = require('codeceptjs').event;
const Apis = require('./rest/openMrsApis');
/**
* Attaches handlers to Codeceptjs events.
* All high level event handlers should be attached in this file.
* Right now this function listens for when a test has completed
* and cleans up any data that was injected into the database
* during the test.
*/
module.exports = function() {
/** After each test clean up data that was injected into the database */
event.dispatcher.on(event.test.after, async (test) => {
try{
// Remove any and all data that was injected into the DB
// after each test
await Apis.cleanUp();
async waitUntilBlock(expectedHeight, counter) {
const {
data: { height },
} = await this.call().getNodeStatus();
const pendingTrxCnt = await this.getPendingTransactionCount();
counter = counter ? (counter += 1) : 1;
output.print(
`Counter: ${counter}, Timestamp: ${new Date().toISOString()}, current height: ${height}, expected height: ${expectedHeight}, pending trxs: ${pendingTrxCnt}`
);
if (counter >= 20) {
return true;
}
if (height >= expectedHeight) {
// Remove the buffer time when network is stable
if (pendingTrxCnt >= 0) {
await this.wait(BLOCK_TIME);
}
return height;
}
await this.wait(BLOCK_TIME);
const chai = require('chai');
const elements = require('lisk-elements');
const output = require('codeceptjs').output;
const API = require('./api.js');
const {
config,
GENESIS_ACCOUNT,
ASGARD_FIXTURE,
seedNode,
networkIdentifier,
} = require('../fixtures');
const { TO_BEDDOWS, BLOCK_TIME, from } = require('../utils');
const users = {};
chai.config.truncateThreshold = 0;
/* eslint camelcase: ["error", {allow: ["codecept_helper"]}] */
const Helper = codecept_helper;
const output = require('codeceptjs').output;
const chai = require('chai');
const apiSchema = require('../api_schema');
const { TO_LISK, TO_BEDDOWS, from, sortBy, flattern } = require('../utils');
const LiskUtil = require('./lisk_util');
/* eslint camelcase: ["error", {allow: ["codecept_helper"]}] */
const Helper = codecept_helper;
const liskUtil = new LiskUtil();
chai.use(require('chai-json-schema'));
chai.use(require('chai-sorted'));
chai.use(require('chai-bignumber')());
const expect = chai.expect;
const otherFields = [
'username',
const splitDelegatesByPeers = (delegates, peers) => {
if (peers.length === 0) {
output.print(
'\n',
'***********Please run npm run tools:peers:config to generate peer list*************',
'\n'
);
process.exit(1);
}
if (peers.length > 101) {
peers.splice(101);
}
const chunkSize = Math.ceil(delegates.length / peers.length);
const delegateList = chunkArray(delegates, chunkSize);
return delegateList;
};
Scenario('List peers', async () => {
try {
const allPeers = await I.getAllPeers(100, 0);
output.print('Peers config list: ', JSON.stringify(allPeers, null, '\t'));
} catch (error) {
output.print('Failed to get peers list: ');
output.error(error);
process.exit(1);
}
})
.tag('@peers_list');
expectVotersResultToMatchParams(response, params) {
try {
Object.entries(params).forEach(item => {
const [k, v] = item;
if (['sort'].includes(k)) {
const [field, order] = v.split(':');
this.expectResponseToBeSortedBy(response.data.voters, field, order);
} else if (k !== 'limit') {
expect(response.data[k].toString()).to.deep.equal(v);
}
});
} catch (error) {
output.error(error);
}
}
expectVotesResultToMatchParams(response, params) {
try {
Object.entries(params).forEach(item => {
const [k, v] = item;
if (['sort'].includes(k)) {
const [field, order] = v.split(':');
this.expectResponseToBeSortedBy(response.data.votes, field, order);
} else if (k !== 'limit') {
expect(response.data[k].toString()).to.deep.equal(v);
}
});
} catch (error) {
output.error(error);
}
}