Skip to content

Commit 4165200

Browse files
rg911fboucquez
andauthored
9.6.1 with pagination on Transaction/Block/Mosaic (#601)
* Updated address (25 bytes => 24 bytes) * 961 patch changes applied * Added UnresolvedMosaicId * Added A, I, Q, Y check on address * Gernate MosaicId by address now * - A few issues fixed. - Integration tests fixed - updated openAPI and catbuffer lib version * mosaic test vector * Fixed mosaic vector test * Fixed mosaic id test vector tests * - updated networkd properties fields - added size to blockInfo * Remvoed meta.id from createFromDto since all ids are from the top level * - Updated openAPI version - Fixed e2e tests * Added MultisigAccounts.spect.ts * - Updated opneAPI spec - Split transaction search & get into 3 - Made 'group' mandatory in transactionSearchCriteria - Added transactionStatus repository * Fixed unit test * Added some unit tests * - Renamed TransactionSearchGroup -> TransactionGroup - Removed transactionGroup from getEffectiveFees - Other PR comments fixed * Fixed doc * Improved test coverage * - Added missing export - More coverage improvment * Fixed missing version in detached cosignature issue * - Updated openAPI version - Fixed a small issues in e2e tests Co-authored-by: fernando <fboucquez@gmail.com>
1 parent fe4cff0 commit 4165200

File tree

171 files changed

+4125
-1839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+4125
-1839
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('AccountHttp', () => {
134134
Deadline.create(),
135135
2,
136136
1,
137-
[cosignAccount1.publicAccount, cosignAccount2.publicAccount, cosignAccount3.publicAccount],
137+
[cosignAccount1.address, cosignAccount2.address, cosignAccount3.address],
138138
[],
139139
networkType,
140140
helper.maxFee,
@@ -177,21 +177,6 @@ describe('AccountHttp', () => {
177177
});
178178
});
179179

180-
describe('getMultisigAccountGraphInfo', () => {
181-
it('should call getMultisigAccountGraphInfo successfully', async () => {
182-
const multisigAccountGraphInfo = await multisigRepository
183-
.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address)
184-
.toPromise();
185-
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
186-
});
187-
});
188-
describe('getMultisigAccountInfo', () => {
189-
it('should call getMultisigAccountInfo successfully', async () => {
190-
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
191-
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigAccount.publicKey);
192-
});
193-
});
194-
195180
describe('transactions', () => {
196181
it('should not return accounts when account does not exist', () => {
197182
return accountRepository
@@ -218,6 +203,21 @@ describe('AccountHttp', () => {
218203
});
219204
});
220205

206+
describe('getMultisigAccountGraphInfo', () => {
207+
it('should call getMultisigAccountGraphInfo successfully', async () => {
208+
await new Promise((resolve) => setTimeout(resolve, 3000));
209+
const multisigAccountGraphInfo = await multisigRepository
210+
.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address)
211+
.toPromise();
212+
expect(multisigAccountGraphInfo.multisigEntries.get(0)![0].accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
213+
});
214+
});
215+
describe('getMultisigAccountInfo', () => {
216+
it('should call getMultisigAccountInfo successfully', async () => {
217+
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
218+
expect(multisigAccountInfo.accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
219+
});
220+
});
221221
/**
222222
* =========================
223223
* House Keeping
@@ -245,7 +245,7 @@ describe('AccountHttp', () => {
245245
-1,
246246
0,
247247
[],
248-
[cosignAccount1.publicAccount],
248+
[cosignAccount1.address],
249249
networkType,
250250
helper.maxFee,
251251
);
@@ -254,7 +254,7 @@ describe('AccountHttp', () => {
254254
0,
255255
0,
256256
[],
257-
[cosignAccount2.publicAccount],
257+
[cosignAccount2.address],
258258
networkType,
259259
helper.maxFee,
260260
);
@@ -264,7 +264,7 @@ describe('AccountHttp', () => {
264264
-1,
265265
-1,
266266
[],
267-
[cosignAccount3.publicAccount],
267+
[cosignAccount3.address],
268268
networkType,
269269
helper.maxFee,
270270
);

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('BlockHttp', () => {
9191
expect(blockInfo.height.higher).to.be.equal(0);
9292
expect(blockInfo.timestamp.lower).to.be.equal(0);
9393
expect(blockInfo.timestamp.higher).to.be.equal(0);
94-
expect(blockInfo.beneficiaryPublicKey).not.to.be.undefined;
94+
expect(blockInfo.beneficiaryAddress).not.to.be.undefined;
9595
expect(blockInfo.numStatements).not.to.be.undefined;
9696
});
9797
});

e2e/infrastructure/IntegrationTestHelper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export class IntegrationTestHelper {
108108
this.account3 = this.createAccount(parsedYaml.nemesis_addresses[2]);
109109
this.multisigAccount = this.createAccount(parsedYaml.nemesis_addresses[3]);
110110
this.cosignAccount1 = this.createAccount(parsedYaml.nemesis_addresses[4]);
111-
this.cosignAccount4 = this.createAccount(parsedYaml.nemesis_addresses[5]);
111+
this.cosignAccount2 = this.createAccount(parsedYaml.nemesis_addresses[5]);
112+
this.cosignAccount3 = this.createAccount(parsedYaml.nemesis_addresses[6]);
113+
this.cosignAccount4 = this.createAccount(parsedYaml.nemesis_addresses[7]);
112114
this.harvestingAccount = this.createAccount(parsedYaml.nemesis_addresses_harvesting[0]);
113115
return resolve(this);
114116
}

e2e/infrastructure/Listener.spec.ts

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@
1515
*/
1616
import { assert, expect } from 'chai';
1717
import { ChronoUnit } from 'js-joda';
18-
import { filter } from 'rxjs/operators';
18+
import { filter, mergeMap } from 'rxjs/operators';
1919
import { TransactionRepository } from '../../src/infrastructure/TransactionRepository';
2020
import { Account } from '../../src/model/account/Account';
2121
import { PlainMessage } from '../../src/model/message/PlainMessage';
22-
import { Address, CosignatureTransaction, LockFundsTransaction, Mosaic, SignedTransaction, UInt64 } from '../../src/model/model';
23-
import { MosaicId } from '../../src/model/mosaic/MosaicId';
24-
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
2522
import { NetworkType } from '../../src/model/network/NetworkType';
2623
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
2724
import { Deadline } from '../../src/model/transaction/Deadline';
2825
import { MultisigAccountModificationTransaction } from '../../src/model/transaction/MultisigAccountModificationTransaction';
2926
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
3027
import { IntegrationTestHelper } from './IntegrationTestHelper';
3128
import { TransactionSearchCriteria } from '../../src/infrastructure/searchCriteria/TransactionSearchCriteria';
32-
import { TransactionGroupSubsetEnum } from 'symbol-openapi-typescript-node-client';
29+
import { Address } from '../../src/model/account/Address';
30+
import { SignedTransaction } from '../../src/model/transaction/SignedTransaction';
31+
import { LockFundsTransaction } from '../../src/model/transaction/LockFundsTransaction';
32+
import { UInt64 } from '../../src/model/UInt64';
33+
import { Mosaic } from '../../src/model/mosaic/Mosaic';
34+
import { CosignatureTransaction } from '../../src/model/transaction/CosignatureTransaction';
35+
import { UnresolvedMosaicId } from '../../src/model/mosaic/UnresolvedMosaicId';
36+
import { TransactionGroup } from '../../src/infrastructure/TransactionGroup';
3337

3438
describe('Listener', () => {
3539
const helper = new IntegrationTestHelper();
@@ -41,7 +45,6 @@ describe('Listener', () => {
4145
let cosignAccount3: Account;
4246
let generationHash: string;
4347
let networkType: NetworkType;
44-
const NetworkCurrencyLocalId: NamespaceId = helper.networkCurrencyNamespaceId;
4548
let transactionRepository: TransactionRepository;
4649

4750
before(() => {
@@ -92,7 +95,7 @@ describe('Listener', () => {
9295
const createHashLockTransactionAndAnnounce = (
9396
signedAggregatedTransaction: SignedTransaction,
9497
signer: Account,
95-
mosaicId: MosaicId | NamespaceId,
98+
mosaicId: UnresolvedMosaicId,
9699
): void => {
97100
const lockFundsTransaction = LockFundsTransaction.create(
98101
Deadline.create(),
@@ -182,7 +185,7 @@ describe('Listener', () => {
182185
const transferTransaction = TransferTransaction.create(
183186
Deadline.create(),
184187
cosignAccount1.address,
185-
[new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility)))],
188+
[helper.createNetworkCurrency(10, true)],
186189
PlainMessage.create('test-message'),
187190
networkType,
188191
helper.maxFee,
@@ -199,7 +202,7 @@ describe('Listener', () => {
199202
Deadline.create(),
200203
2,
201204
1,
202-
[cosignAccount1.publicAccount, cosignAccount2.publicAccount, cosignAccount3.publicAccount],
205+
[cosignAccount1.address, cosignAccount2.address, cosignAccount3.address],
203206
[],
204207
networkType,
205208
helper.maxFee,
@@ -225,7 +228,7 @@ describe('Listener', () => {
225228
describe('Aggregate Bonded Transactions', () => {
226229
it('aggregateBondedTransactionsAdded', (done) => {
227230
const signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address);
228-
createHashLockTransactionAndAnnounce(signedAggregatedTx, account, NetworkCurrencyLocalId);
231+
createHashLockTransactionAndAnnounce(signedAggregatedTx, account, helper.networkCurrencyNamespaceId);
229232
helper.listener.aggregateBondedAdded(account.address).subscribe(() => {
230233
done();
231234
});
@@ -239,26 +242,34 @@ describe('Listener', () => {
239242
});
240243
});
241244
});
245+
242246
describe('Aggregate Bonded Transactions', () => {
243247
it('aggregateBondedTransactionsRemoved', (done) => {
244248
const signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.address);
245-
246-
createHashLockTransactionAndAnnounce(signedAggregatedTx, cosignAccount1, NetworkCurrencyLocalId);
249+
createHashLockTransactionAndAnnounce(signedAggregatedTx, cosignAccount1, helper.networkCurrencyNamespaceId);
250+
helper.listener.aggregateBondedRemoved(cosignAccount1.address, signedAggregatedTx.hash).subscribe(() => {
251+
done();
252+
});
247253
helper.listener.confirmed(cosignAccount1.address).subscribe(() => {
248-
helper.listener.aggregateBondedRemoved(cosignAccount1.address).subscribe(() => {
249-
done();
250-
});
251254
helper.listener.aggregateBondedAdded(cosignAccount1.address).subscribe(() => {
252255
const criteria: TransactionSearchCriteria = {
253-
address: cosignAccount1.publicAccount.address,
254-
group: TransactionGroupSubsetEnum.Partial,
256+
address: cosignAccount1.address,
257+
group: TransactionGroup.Partial,
258+
embedded: true,
255259
};
256-
transactionRepository.search(criteria).subscribe((transactions) => {
257-
const transactionToCosign = transactions[0];
258-
const cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
259-
const cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
260-
transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction);
261-
});
260+
transactionRepository
261+
.search(criteria)
262+
.pipe(
263+
mergeMap((page) => {
264+
return transactionRepository.getTransaction(page.data[0].transactionInfo?.hash!, TransactionGroup.Partial);
265+
}),
266+
)
267+
.subscribe((transactions) => {
268+
const transactionToCosign = transactions as AggregateTransaction;
269+
const cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
270+
const cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
271+
transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction);
272+
});
262273
});
263274
helper.listener.status(cosignAccount1.address).subscribe((error) => {
264275
console.log('Error:', error);
@@ -279,17 +290,17 @@ describe('Listener', () => {
279290
it('cosignatureAdded', (done) => {
280291
const signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.address);
281292

282-
createHashLockTransactionAndAnnounce(signedAggregatedTx, cosignAccount1, NetworkCurrencyLocalId);
293+
createHashLockTransactionAndAnnounce(signedAggregatedTx, cosignAccount1, helper.networkCurrencyNamespaceId);
283294
helper.listener.cosignatureAdded(cosignAccount1.address).subscribe(() => {
284295
done();
285296
});
286297
helper.listener.aggregateBondedAdded(cosignAccount1.address).subscribe(() => {
287298
const criteria: TransactionSearchCriteria = {
288299
address: cosignAccount1.publicAccount.address,
289-
group: TransactionGroupSubsetEnum.Partial,
300+
group: TransactionGroup.Partial,
290301
};
291302
transactionRepository.search(criteria).subscribe((transactions) => {
292-
const transactionToCosign = transactions[0];
303+
const transactionToCosign = transactions.data[0] as AggregateTransaction;
293304
const cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
294305
const cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
295306
transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction);
@@ -313,15 +324,15 @@ describe('Listener', () => {
313324
-1,
314325
0,
315326
[],
316-
[cosignAccount1.publicAccount],
327+
[cosignAccount1.address],
317328
networkType,
318329
);
319330
const removeCosigner2 = MultisigAccountModificationTransaction.create(
320331
Deadline.create(),
321332
0,
322333
0,
323334
[],
324-
[cosignAccount2.publicAccount],
335+
[cosignAccount2.address],
325336
networkType,
326337
);
327338

@@ -330,7 +341,7 @@ describe('Listener', () => {
330341
-1,
331342
-1,
332343
[],
333-
[cosignAccount3.publicAccount],
344+
[cosignAccount3.address],
334345
networkType,
335346
);
336347

@@ -343,6 +354,7 @@ describe('Listener', () => {
343354
],
344355
networkType,
345356
[],
357+
helper.maxFee,
346358
);
347359
const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(
348360
cosignAccount1,

0 commit comments

Comments
 (0)