Skip to content

Commit f6f62c0

Browse files
authored
Merge pull request #435 from NEMStudios/master
Rolled back transactionHelper changes
2 parents fdabe83 + f52bc23 commit f6f62c0

File tree

55 files changed

+1178
-1070
lines changed

Some content is hidden

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

55 files changed

+1178
-1070
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
17+
import { assert, expect } from 'chai';
1818
import { AccountRepository } from '../../src/infrastructure/AccountRepository';
1919
import { MultisigRepository } from '../../src/infrastructure/MultisigRepository';
2020
import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository';
@@ -171,42 +171,59 @@ describe('AccountHttp', () => {
171171
*/
172172

173173
describe('getAccountInfo', () => {
174-
it('should return account data given a NEM Address', async () => {
175-
const accountInfo = await accountRepository.getAccountInfo(accountAddress).toPromise();
176-
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);
174+
it('should return account data given a NEM Address', (done) => {
175+
accountRepository.getAccountInfo(accountAddress)
176+
.subscribe((accountInfo) => {
177+
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);
178+
done();
179+
});
177180
});
178181
});
179182

180183
describe('getAccountsInfo', () => {
181-
it('should return account data given a NEM Address', async () => {
182-
const accountsInfo = await accountRepository.getAccountsInfo([accountAddress]).toPromise();
183-
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
184+
it('should return account data given a NEM Address', (done) => {
185+
accountRepository.getAccountsInfo([accountAddress])
186+
.subscribe((accountsInfo) => {
187+
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
188+
done();
189+
});
184190
});
185191
});
186192

187193
describe('getMultisigAccountGraphInfo', () => {
188-
it('should call getMultisigAccountGraphInfo successfully', async () => {
189-
const multisigAccountGraphInfo = await multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address).toPromise();
190-
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
194+
it('should call getMultisigAccountGraphInfo successfully', (done) => {
195+
multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address).subscribe((multisigAccountGraphInfo) => {
196+
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
197+
done();
198+
});
191199
});
192200
});
193201
describe('getMultisigAccountInfo', () => {
194-
it('should call getMultisigAccountInfo successfully', async () => {
195-
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
196-
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigAccount.publicKey);
202+
it('should call getMultisigAccountInfo successfully', (done) => {
203+
multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).subscribe((multisigAccountInfo) => {
204+
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigAccount.publicKey);
205+
done();
206+
});
197207
});
198208
});
199209

200210
describe('outgoingTransactions', () => {
201-
it('should call outgoingTransactions successfully', async () => {
202-
const transactions = await accountRepository.getAccountOutgoingTransactions(publicAccount.address).toPromise();
203-
expect(transactions.length).to.be.greaterThan(0);
211+
it('should call outgoingTransactions successfully', (done) => {
212+
accountRepository.getAccountOutgoingTransactions(publicAccount.address).subscribe((transactions) => {
213+
expect(transactions.length).to.be.greaterThan(0);
214+
done();
215+
});
204216
});
205217
});
206218

207219
describe('aggregateBondedTransactions', () => {
208-
it('should call aggregateBondedTransactions successfully', async () => {
209-
await accountRepository.getAccountPartialTransactions(publicAccount.address).toPromise();
220+
it('should call aggregateBondedTransactions successfully', (done) => {
221+
accountRepository.getAccountPartialTransactions(publicAccount.address).subscribe(() => {
222+
done();
223+
}, (error) => {
224+
console.log('Error:', error);
225+
assert(false);
226+
});
210227
});
211228
});
212229

@@ -226,6 +243,7 @@ describe('AccountHttp', () => {
226243
describe('transactions', () => {
227244
it('should call transactions successfully by type', async () => {
228245
const transactions = await accountRepository.getAccountTransactions(publicAccount.address, {transactionType: TransactionType.TRANSFER} as QueryParams).toPromise();
246+
229247
expect(transactions.length).to.be.greaterThan(0);
230248
transactions.forEach((t) => {
231249
expect(t.type).to.be.eq(TransactionType.TRANSFER);
@@ -234,23 +252,29 @@ describe('AccountHttp', () => {
234252
});
235253

236254
describe('transactions', () => {
237-
it('should call transactions successfully', async () => {
238-
const transactions = await accountRepository.getAccountTransactions(publicAccount.address).toPromise();
239-
expect(transactions.length).to.be.greaterThan(0);
255+
it('should call transactions successfully', (done) => {
256+
accountRepository.getAccountTransactions(publicAccount.address).subscribe((transactions) => {
257+
expect(transactions.length).to.be.greaterThan(0);
258+
done();
259+
});
240260
});
241261
});
242262

243263
describe('unconfirmedTransactions', () => {
244-
it('should call unconfirmedTransactions successfully', async () => {
245-
const transactions = await accountRepository.getAccountUnconfirmedTransactions(publicAccount.address).toPromise();
246-
expect(transactions.length).to.be.equal(0);
264+
it('should call unconfirmedTransactions successfully', (done) => {
265+
accountRepository.getAccountUnconfirmedTransactions(publicAccount.address).subscribe((transactions) => {
266+
expect(transactions.length).to.be.equal(0);
267+
done();
268+
});
247269
});
248270
});
249271

250272
describe('getAddressNames', () => {
251-
it('should call getAddressNames successfully', async () => {
252-
const addressNames = await namespaceRepository.getAccountsNames([accountAddress]).toPromise();
253-
expect(addressNames.length).to.be.greaterThan(0);
273+
it('should call getAddressNames successfully', (done) => {
274+
namespaceRepository.getAccountsNames([accountAddress]).subscribe((addressNames) => {
275+
expect(addressNames.length).to.be.greaterThan(0);
276+
done();
277+
});
254278
});
255279
});
256280

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('BlockHttp', () => {
6969

7070
describe('Setup Test Data', () => {
7171

72-
it('Announce TransferTransaction', () => {
72+
it('Announce TransferTransaction', (done) => {
7373
const transferTransaction = TransferTransaction.create(
7474
Deadline.create(),
7575
account2.address,
@@ -79,79 +79,99 @@ describe('BlockHttp', () => {
7979
helper.maxFee,
8080
);
8181
const signedTransaction = transferTransaction.signWith(account, generationHash);
82-
return helper.announce(signedTransaction).then((transaction) => {
82+
helper.announce(signedTransaction).then((transaction) => {
8383
chainHeight = transaction.transactionInfo!.height.toString();
84-
return chainHeight;
84+
done();
8585
});
8686
});
8787
});
8888

8989
describe('getBlockByHeight', () => {
90-
it('should return block info given height', async () => {
91-
const blockInfo = await blockRepository.getBlockByHeight(UInt64.fromUint(1)).toPromise();
92-
blockReceiptHash = blockInfo.blockReceiptsHash;
93-
blockTransactionHash = blockInfo.blockTransactionsHash;
94-
expect(blockInfo.height.lower).to.be.equal(1);
95-
expect(blockInfo.height.higher).to.be.equal(0);
96-
expect(blockInfo.timestamp.lower).to.be.equal(0);
97-
expect(blockInfo.timestamp.higher).to.be.equal(0);
98-
90+
it('should return block info given height', (done) => {
91+
blockRepository.getBlockByHeight(UInt64.fromUint(1))
92+
.subscribe((blockInfo) => {
93+
blockReceiptHash = blockInfo.blockReceiptsHash;
94+
blockTransactionHash = blockInfo.blockTransactionsHash;
95+
expect(blockInfo.height.lower).to.be.equal(1);
96+
expect(blockInfo.height.higher).to.be.equal(0);
97+
expect(blockInfo.timestamp.lower).to.be.equal(0);
98+
expect(blockInfo.timestamp.higher).to.be.equal(0);
99+
done();
100+
});
99101
});
100102
});
101103

102104
describe('getBlockTransactions', () => {
103105
let nextId: string;
104106
let firstId: string;
105107

106-
it('should return block transactions data given height', async () => {
107-
const transactions = await blockRepository.getBlockTransactions(UInt64.fromUint(1)).toPromise();
108-
nextId = transactions[0].transactionInfo!.id;
109-
firstId = transactions[1].transactionInfo!.id;
110-
expect(transactions.length).to.be.greaterThan(0);
108+
it('should return block transactions data given height', (done) => {
109+
blockRepository.getBlockTransactions(UInt64.fromUint(1))
110+
.subscribe((transactions) => {
111+
nextId = transactions[0].transactionInfo!.id;
112+
firstId = transactions[1].transactionInfo!.id;
113+
expect(transactions.length).to.be.greaterThan(0);
114+
done();
115+
});
111116
});
112117

113-
it('should return block transactions data given height with paginated transactionId', async () => {
114-
const transactions = await blockRepository.getBlockTransactions(UInt64.fromUint(1), new QueryParams(10, nextId)).toPromise();
115-
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
116-
expect(transactions.length).to.be.greaterThan(0);
118+
it('should return block transactions data given height with paginated transactionId', (done) => {
119+
blockRepository.getBlockTransactions(UInt64.fromUint(1), new QueryParams(10, nextId))
120+
.subscribe((transactions) => {
121+
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
122+
expect(transactions.length).to.be.greaterThan(0);
123+
done();
124+
});
117125
});
118126
});
119127

120128
describe('getBlocksByHeightWithLimit', () => {
121-
it('should return block info given height and limit', async () => {
122-
const blocksInfo = await blockRepository.getBlocksByHeightWithLimit(chainHeight, 50).toPromise();
123-
expect(blocksInfo.length).to.be.greaterThan(0);
129+
it('should return block info given height and limit', (done) => {
130+
blockRepository.getBlocksByHeightWithLimit(chainHeight, 50)
131+
.subscribe((blocksInfo) => {
132+
expect(blocksInfo.length).to.be.greaterThan(0);
133+
done();
134+
});
124135
});
125136
});
126137
describe('getMerkleReceipts', () => {
127-
it('should return Merkle Receipts', async () => {
128-
const merkleReceipts = await receiptRepository.getBlockReceipts(chainHeight).pipe(
138+
it('should return Merkle Receipts', (done) => {
139+
receiptRepository.getBlockReceipts(chainHeight).pipe(
129140
mergeMap((_) => {
130141
return receiptRepository.getMerkleReceipts(chainHeight, _.transactionStatements[0].generateHash());
131-
})).toPromise();
132-
expect(merkleReceipts.merklePath).not.to.be.null;
142+
}))
143+
.subscribe((merkleReceipts) => {
144+
expect(merkleReceipts.merklePath).not.to.be.null;
145+
done();
146+
});
133147
});
134148
});
135149
describe('getMerkleTransaction', () => {
136-
it('should return Merkle Transaction', async () => {
137-
const merkleTransactionss = await blockRepository.getBlockTransactions(chainHeight).pipe(
150+
it('should return Merkle Transaction', (done) => {
151+
blockRepository.getBlockTransactions(chainHeight).pipe(
138152
mergeMap((_) => {
139153
const hash = (_[0].transactionInfo as TransactionInfo).hash;
140154
if (hash) {
141155
return blockRepository.getMerkleTransaction(chainHeight, hash);
142156
}
143157
// If reaching this line, something is not right
144158
throw new Error('Tansacation hash is undefined');
145-
})).toPromise();
146-
expect(merkleTransactionss.merklePath).not.to.be.null;
159+
}))
160+
.subscribe((merkleTransactionss) => {
161+
expect(merkleTransactionss.merklePath).not.to.be.null;
162+
done();
163+
});
147164
});
148165
});
149166

150167
describe('getBlockReceipts', () => {
151-
it('should return block receipts', async () => {
152-
const statement = await receiptRepository.getBlockReceipts(chainHeight).toPromise();
153-
expect(statement.transactionStatements).not.to.be.null;
154-
expect(statement.transactionStatements.length).to.be.greaterThan(0);
168+
it('should return block receipts', (done) => {
169+
receiptRepository.getBlockReceipts(chainHeight)
170+
.subscribe((statement) => {
171+
expect(statement.transactionStatements).not.to.be.null;
172+
expect(statement.transactionStatements.length).to.be.greaterThan(0);
173+
done();
174+
});
155175
});
156176
});
157177
});

e2e/infrastructure/ChainHttp.spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,24 @@ describe('ChainHttp', () => {
2929
});
3030

3131
describe('getBlockchainHeight', () => {
32-
it('should return blockchain height', async () => {
33-
const height = await chainRepository.getBlockchainHeight().toPromise();
34-
expect(height.lower).to.be.greaterThan(0);
32+
it('should return blockchain height', (done) => {
33+
chainRepository.getBlockchainHeight()
34+
.subscribe((height) => {
35+
expect(height.lower).to.be.greaterThan(0);
36+
done();
37+
});
3538
});
3639
});
3740

3841
describe('getBlockchainScore', () => {
39-
it('should return blockchain score', async () => {
40-
const blockchainScore = await chainRepository.getChainScore().toPromise();
41-
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
42-
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
43-
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
42+
it('should return blockchain score', (done) => {
43+
chainRepository.getChainScore()
44+
.subscribe((blockchainScore) => {
45+
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
46+
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
47+
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
48+
done();
49+
});
4450
});
4551
});
4652
});

e2e/infrastructure/DiagnosticHttp.spec.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,25 @@ describe('DiagnosticHttp', () => {
2929
});
3030

3131
describe('getDiagnosticStorage', () => {
32-
it('should return diagnostic storage', async () => {
33-
const blockchainStorageInfo = await diagnosticRepository.getDiagnosticStorage().toPromise();
34-
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
35-
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
36-
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
32+
it('should return diagnostic storage', (done) => {
33+
diagnosticRepository.getDiagnosticStorage()
34+
.subscribe((blockchainStorageInfo) => {
35+
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
36+
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
37+
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
38+
done();
39+
});
3740
});
3841
});
3942

4043
describe('getServerInfo', () => {
41-
it('should return diagnostic storage', async () => {
42-
const serverInfo = await diagnosticRepository.getServerInfo().toPromise();
43-
expect(serverInfo.restVersion).not.to.be.null;
44-
expect(serverInfo.sdkVersion).not.to.be.null;
44+
it('should return diagnostic storage', (done) => {
45+
diagnosticRepository.getServerInfo()
46+
.subscribe((serverInfo) => {
47+
expect(serverInfo.restVersion).not.to.be.null;
48+
expect(serverInfo.sdkVersion).not.to.be.null;
49+
done();
50+
});
4551
});
4652
});
4753
});

e2e/infrastructure/IntegrationTestHelper.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ export class IntegrationTestHelper {
7373
// What would be the best maxFee? In the future we will load the fee multiplier from rest.
7474
this.maxFee = UInt64.fromUint(1000000);
7575

76-
const bootstrapRoot = process.env.CATAPULT_SERVICE_BOOTSTRAP || path.resolve(__dirname, '../../../../catapult-service-bootstrap');
77-
const bootstrapPath = `${bootstrapRoot}/build/generated-addresses/addresses.yaml`;
78-
require('fs').readFile(bootstrapPath, (error: any, yamlData: any) => {
76+
require('fs').readFile(path.resolve(__dirname,
77+
'../../../catapult-service-bootstrap/build/generated-addresses/addresses.yaml'),
78+
(error: any, yamlData: any) => {
7979
if (error) {
80-
console.log(`catapult-service-bootstrap generated address could not be loaded from path ${bootstrapPath}. Ignoring and using accounts from network.conf.`);
80+
console.log(`catapult-service-bootstrap generated address could not be loaded. Ignoring and using accounts from network.conf.`);
8181
return resolve(this);
8282
} else {
83-
console.log(`catapult-service-bootstrap generated address loaded from path ${bootstrapPath}.`);
8483
const parsedYaml = this.yaml.safeLoad(yamlData);
8584
this.account = this.createAccount(parsedYaml.nemesis_addresses[0]);
8685
this.account2 = this.createAccount(parsedYaml.nemesis_addresses[1]);

0 commit comments

Comments
 (0)