Skip to content

Commit

Permalink
Merge 503c278 into 7b91ea5
Browse files Browse the repository at this point in the history
  • Loading branch information
rg911 committed Aug 15, 2019
2 parents 7b91ea5 + 503c278 commit 92643d1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/model/transaction/AggregateTransaction.ts
Expand Up @@ -115,6 +115,17 @@ export class AggregateTransaction extends Transaction {
);
}

/**
* @description add inner transactions to current list
* @param {InnerTransaction[]} transaction
* @returns {AggregateTransaction}
* @memberof AggregateTransaction
*/
public addTransactions(transactions: InnerTransaction[]): AggregateTransaction {
const innerTransactions = this.innerTransactions.concat(transactions);
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {innerTransactions});
}

/**
* @internal
* @returns {AggregateTransaction}
Expand Down
27 changes: 27 additions & 0 deletions test/model/transaction/AggregateTransaction.spec.ts
Expand Up @@ -454,6 +454,33 @@ describe('AggregateTransaction', () => {
expect(standardCosignedTransaction.hash).to.be.equal(signedTransaction.hash);
});

it('Should be able to add innertransactions to current aggregate tx', () => {
const transferTx1 = TransferTransaction.create(Deadline.create(),
account.address,
[],
PlainMessage.create('a to b'),
NetworkType.MIJIN_TEST);
const transferTx2 = TransferTransaction.create(Deadline.create(),
account.address,
[],
PlainMessage.create('b to a'),
NetworkType.MIJIN_TEST);
let aggregateTransaction = AggregateTransaction.createComplete(
Deadline.create(),
[transferTx1.toAggregate(account.publicAccount)],
NetworkType.MIJIN_TEST,
[],
);

expect(aggregateTransaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE);
expect(aggregateTransaction.innerTransactions.length).to.be.equal(1);

aggregateTransaction = aggregateTransaction.addTransactions([transferTx2.toAggregate(account.publicAccount)]);

expect(aggregateTransaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE);
expect(aggregateTransaction.innerTransactions.length).to.be.equal(2);
});

describe('size', () => {
it('should return 282 for AggregateTransaction byte size with TransferTransaction with 1 mosaic and message NEM', () => {
const transaction = TransferTransaction.create(
Expand Down

0 comments on commit 92643d1

Please sign in to comment.