Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
localCommon.getNextForger(library, null, (err, delegatePublicKey) => {
lastBlock = library.modules.blocks.lastBlock.get();
lastBlockForger = delegatePublicKey;
tmpAccount = randomUtil.account();
// Create transfer transaction (fund new account)
let transaction = elements.transaction.transfer({
recipientId: tmpAccount.address,
amount: 5000000000,
passphrase: accountsFixtures.genesis.passphrase,
});
transactions.transfer.push(transaction);
// Create register delegate transaction
transaction = elements.transaction.registerDelegate({
passphrase: tmpAccount.passphrase,
username: 'my_little_delegate',
});
transactions.delegate.push(transaction);
transaction = elements.transaction.castVotes({
passphrase: accountsFixtures.genesis.passphrase,
unvotes: [lastBlockForger],
votes: [tmpAccount.publicKey],
});
transactions.vote.push(transaction);
const transactionPool = library.rewiredModules.transactions.__get__(
'__private.transactionPool'
);
// Delete two blocks more
it('with lowercase recipientId should fail', () => {
transaction = randomUtil.transaction();
transaction.recipientId = transaction.recipientId.toLowerCase();
transaction.signature = crypto.randomBytes(64).toString('hex');
transaction.id = lisk.transaction.utils.getTransactionId(transaction);
return sendTransactionPromise(transaction, 400).then(res => {
expect(res.body.message).to.be.equal('Validation errors');
badTransactions.push(transaction);
});
});
});
it('should return error when value is greater than maximum acceptable value', () => {
const minimum = MULTISIG_CONSTRAINTS.MIN.MAXIMUM + 1;
const keysgroup = [
multiSigAccount1.publicKey,
multiSigAccount2.publicKey,
];
const multisigRegistration6 = lisk.transaction.registerMultisignature({
passphrase: accountFixtures.genesis.passphrase,
keysgroup,
lifetime: 1,
minimum,
});
return expect(() => {
multisignature.objectNormalize(multisigRegistration6);
}).to.throw(
'Failed to validate multisignature schema: Value 16 is greater than maximum 15'
);
});
it('requesting multisig group transaction from non author account', () => {
var scenario = scenarios.requesterPublicKey;
var transaction = lisk.transaction.transfer({
amount: 1 * NORMALIZER,
passphrase: scenario.members[0].passphrase,
recipientId: randomUtil.account().address,
});
transaction.requesterPublicKey = scenario.account.publicKey;
transaction.id = lisk.transaction.utils.getTransactionId(transaction);
return sendTransactionPromise(
transaction,
errorCodes.PROCESSING_ERROR
).then(res => {
expect(res.body.message).to.equal('Multisig request is not allowed');
badTransactions.push(transaction);
});
});
});
it('adding to pool second signature registration should be ok', done => {
transaction1 = lisk.transaction.registerSecondPassphrase({
passphrase: account.passphrase,
secondPassphrase: account.secondPassphrase,
timeOffset: -10000,
});
localCommon.addTransaction(library, transaction1, (err, res) => {
expect(res).to.equal(transaction1.id);
done();
});
});
const createTransaction = (amount, recipientId) => {
return lisk.transaction.transfer({
recipientId,
amount,
passphrase: accountsFixtures.genesis.passphrase,
});
};
before(() => {
var promises = [];
var transaction;
var transactionsToWaitFor = [];
for (var i = 1; i <= 20; i++) {
transaction = lisk.transaction.createDapp({
passphrase: account.passphrase,
options: randomUtil.application(),
});
transactionsToWaitFor.push(transaction.id);
promises.push(apiHelpers.sendTransactionPromise(transaction));
}
return Promise.all(promises).then(results => {
results.forEach(res => {
expect(res)
.to.have.property('status')
.to.equal(200);
});
return waitFor.confirmations(transactionsToWaitFor);
});
});
before(() => {
var transactions = [];
var transaction1 = lisk.transaction.transfer({
amount: 1000 * NORMALIZER,
passphrase: accountFixtures.genesis.passphrase,
recipientId: delegateAccount.address,
});
var transaction2 = lisk.transaction.transfer({
amount: FEES.VOTE,
passphrase: accountFixtures.genesis.passphrase,
recipientId: accountMinimalFunds.address,
});
var transaction3 = lisk.transaction.transfer({
amount: 1000 * NORMALIZER,
passphrase: accountFixtures.genesis.passphrase,
recipientId: accountFixtures.existingDelegate.address,
});
var transaction4 = lisk.transaction.transfer({
amount: 1000 * NORMALIZER,
_.range(maximum).map(() => {
var tmpAccount = randomUtil.account();
var transaction = lisk.transaction.transfer({
amount: 2500000000,
passphrase: accountFixtures.genesis.passphrase,
recipientId: tmpAccount.address,
});
accounts.push(tmpAccount);
transactions.push(transaction);
return sendTransactionsPromise([transaction]);
})
);
if (secondPassphrase === true) {
accountCopy.secondPassphrase = null;
} else if (secondPassphrase === false) {
accountCopy.secondPassphrase = 'invalid_second_passphrase';
}
switch (key) {
case 'SEND':
transaction = lisk.transaction.transfer({
amount: 1,
passphrase: accountCopy.passphrase,
secondPassphrase: accountCopy.secondPassphrase,
recipientId: randomUtil.account().address,
});
break;
case 'SIGNATURE':
transaction = lisk.transaction.registerSecondPassphrase({
passphrase: account.passphrase,
secondPassphrase: account.secondPassphrase,
});
break;
case 'DELEGATE':
transaction = lisk.transaction.registerDelegate({
passphrase: accountCopy.passphrase,
secondPassphrase: accountCopy.secondPassphrase,
username: accountCopy.username,
});
break;
case 'VOTE':
transaction = lisk.transaction.castVotes({
passphrase: accountCopy.passphrase,
secondPassphrase: accountCopy.secondPassphrase,
votes: [accountFixtures.existingDelegate.publicKey],