Skip to content

Commit

Permalink
[WIP #165] Integration tests for api/multisignatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanever committed Apr 22, 2018
1 parent b1e5373 commit b3e6c5d
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions tests/integration/api/multisignatures.spec.ts
Expand Up @@ -6,6 +6,8 @@ import {
createMultiSignTransaction, createRandomAccountWithFunds, createRandomWallet
} from '../common/utils';
import { Symbols } from '../../../src/ioc/symbols';
import { LiskWallet } from 'dpos-offline';
import { ITransaction } from 'dpos-offline/dist/es5/trxTypes/BaseTx';

// tslint:disable no-unused-expression max-line-length
describe('api/multisignatures', () => {
Expand Down Expand Up @@ -53,11 +55,53 @@ describe('api/multisignatures', () => {
});

describe('/pending', () => {
let sender: LiskWallet;
let signedTx: ITransaction;
checkRequiredParam('publicKey', '/api/multisignatures/pending');
checkPubKey('publicKey', '/api/multisignatures/pending');
checkReturnObjKeyVal('transactions', [], '/api/multisignatures/pending?publicKey=e0f1c6cca365cd61bbb01cfb454828a698fa4b7170e85a597dde510567f9dda5');
it('should have pending transactions object if any missing pending tx is available');
it('should have a min, max, lifetime, signed info for each pending tx');

it('should have pending transactions object if any missing pending tx is available', async () => {
const txModule = initializer.appManager.container.get(Symbols.modules.transactions);
const senderData = await createRandomAccountWithFunds(5000000000);
sender = senderData.wallet;
const keys = [createRandomWallet(), createRandomWallet(), createRandomWallet()];
signedTx = createMultiSignTransaction(sender, 3, keys.map((k) => '+' + k.publicKey));
await txModule.receiveTransactions([signedTx], false, false);
await initializer.rawMineBlocks(1);
return supertest(initializer.appManager.expressApp)
.get('/api/multisignatures/pending?publicKey=' + sender.publicKey)
.expect(200)
.then((response) => {
expect(Array.isArray(response.body.transactions)).to.be.true;
expect(response.body.transactions.length).to.be.eq(1);
expect(response.body.transactions[0].transaction.senderPublicKey).to.be.eq(sender.publicKey);
});

});

it('should have a min, max, lifetime, signed info for each pending tx', async () => {
const txModule = initializer.appManager.container.get(Symbols.modules.transactions);
const senderData = await createRandomAccountWithFunds(5000000000);
sender = senderData.wallet;
const keys = [createRandomWallet(), createRandomWallet(), createRandomWallet()];
signedTx = createMultiSignTransaction(sender, 3, keys.map((k) => '+' + k.publicKey));
await txModule.receiveTransactions([signedTx], false, false);
await initializer.rawMineBlocks(1);
return supertest(initializer.appManager.expressApp)
.get('/api/multisignatures/pending?publicKey=' + sender.publicKey)
.expect(200)
.then((response) => {
expect(Array.isArray(response.body.transactions)).to.be.true;
response.body.transactions.forEach((txObj) => {
expect(txObj.lifetime).to.exist;
expect(txObj.max).to.exist;
expect(txObj.min).to.exist;
expect(txObj.signed).to.exist;
expect(txObj.transaction).to.exist;
});
});
});
});

describe('/sign', () => {
Expand Down

0 comments on commit b3e6c5d

Please sign in to comment.