Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 27 additions & 51 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { assert, expect } from 'chai';
import { expect } from 'chai';
import { AccountRepository } from '../../src/infrastructure/AccountRepository';
import { MultisigRepository } from '../../src/infrastructure/MultisigRepository';
import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository';
Expand Down Expand Up @@ -171,59 +171,42 @@ describe('AccountHttp', () => {
*/

describe('getAccountInfo', () => {
it('should return account data given a NEM Address', (done) => {
accountRepository.getAccountInfo(accountAddress)
.subscribe((accountInfo) => {
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);
done();
});
it('should return account data given a NEM Address', async () => {
const accountInfo = await accountRepository.getAccountInfo(accountAddress).toPromise();
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);
});
});

describe('getAccountsInfo', () => {
it('should return account data given a NEM Address', (done) => {
accountRepository.getAccountsInfo([accountAddress])
.subscribe((accountsInfo) => {
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
done();
});
it('should return account data given a NEM Address', async () => {
const accountsInfo = await accountRepository.getAccountsInfo([accountAddress]).toPromise();
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
});
});

describe('getMultisigAccountGraphInfo', () => {
it('should call getMultisigAccountGraphInfo successfully', (done) => {
multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address).subscribe((multisigAccountGraphInfo) => {
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
done();
});
it('should call getMultisigAccountGraphInfo successfully', async () => {
const multisigAccountGraphInfo = await multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address).toPromise();
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
});
});
describe('getMultisigAccountInfo', () => {
it('should call getMultisigAccountInfo successfully', (done) => {
multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).subscribe((multisigAccountInfo) => {
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigAccount.publicKey);
done();
});
it('should call getMultisigAccountInfo successfully', async () => {
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigAccount.publicKey);
});
});

describe('outgoingTransactions', () => {
it('should call outgoingTransactions successfully', (done) => {
accountRepository.getAccountOutgoingTransactions(publicAccount.address).subscribe((transactions) => {
expect(transactions.length).to.be.greaterThan(0);
done();
});
it('should call outgoingTransactions successfully', async () => {
const transactions = await accountRepository.getAccountOutgoingTransactions(publicAccount.address).toPromise();
expect(transactions.length).to.be.greaterThan(0);
});
});

describe('aggregateBondedTransactions', () => {
it('should call aggregateBondedTransactions successfully', (done) => {
accountRepository.getAccountPartialTransactions(publicAccount.address).subscribe(() => {
done();
}, (error) => {
console.log('Error:', error);
assert(false);
});
it('should call aggregateBondedTransactions successfully', async () => {
await accountRepository.getAccountPartialTransactions(publicAccount.address).toPromise();
});
});

Expand All @@ -243,7 +226,6 @@ describe('AccountHttp', () => {
describe('transactions', () => {
it('should call transactions successfully by type', async () => {
const transactions = await accountRepository.getAccountTransactions(publicAccount.address, {transactionType: TransactionType.TRANSFER} as QueryParams).toPromise();

expect(transactions.length).to.be.greaterThan(0);
transactions.forEach((t) => {
expect(t.type).to.be.eq(TransactionType.TRANSFER);
Expand All @@ -252,29 +234,23 @@ describe('AccountHttp', () => {
});

describe('transactions', () => {
it('should call transactions successfully', (done) => {
accountRepository.getAccountTransactions(publicAccount.address).subscribe((transactions) => {
expect(transactions.length).to.be.greaterThan(0);
done();
});
it('should call transactions successfully', async () => {
const transactions = await accountRepository.getAccountTransactions(publicAccount.address).toPromise();
expect(transactions.length).to.be.greaterThan(0);
});
});

describe('unconfirmedTransactions', () => {
it('should call unconfirmedTransactions successfully', (done) => {
accountRepository.getAccountUnconfirmedTransactions(publicAccount.address).subscribe((transactions) => {
expect(transactions.length).to.be.equal(0);
done();
});
it('should call unconfirmedTransactions successfully', async () => {
const transactions = await accountRepository.getAccountUnconfirmedTransactions(publicAccount.address).toPromise();
expect(transactions.length).to.be.equal(0);
});
});

describe('getAddressNames', () => {
it('should call getAddressNames successfully', (done) => {
namespaceRepository.getAccountsNames([accountAddress]).subscribe((addressNames) => {
expect(addressNames.length).to.be.greaterThan(0);
done();
});
it('should call getAddressNames successfully', async () => {
const addressNames = await namespaceRepository.getAccountsNames([accountAddress]).toPromise();
expect(addressNames.length).to.be.greaterThan(0);
});
});

Expand Down
92 changes: 36 additions & 56 deletions e2e/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('BlockHttp', () => {

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

it('Announce TransferTransaction', (done) => {
it('Announce TransferTransaction', () => {
const transferTransaction = TransferTransaction.create(
Deadline.create(),
account2.address,
Expand All @@ -79,99 +79,79 @@ describe('BlockHttp', () => {
helper.maxFee,
);
const signedTransaction = transferTransaction.signWith(account, generationHash);
helper.announce(signedTransaction).then((transaction) => {
return helper.announce(signedTransaction).then((transaction) => {
chainHeight = transaction.transactionInfo!.height.toString();
done();
return chainHeight;
});
});
});

describe('getBlockByHeight', () => {
it('should return block info given height', (done) => {
blockRepository.getBlockByHeight(UInt64.fromUint(1))
.subscribe((blockInfo) => {
blockReceiptHash = blockInfo.blockReceiptsHash;
blockTransactionHash = blockInfo.blockTransactionsHash;
expect(blockInfo.height.lower).to.be.equal(1);
expect(blockInfo.height.higher).to.be.equal(0);
expect(blockInfo.timestamp.lower).to.be.equal(0);
expect(blockInfo.timestamp.higher).to.be.equal(0);
done();
});
it('should return block info given height', async () => {
const blockInfo = await blockRepository.getBlockByHeight(UInt64.fromUint(1)).toPromise();
blockReceiptHash = blockInfo.blockReceiptsHash;
blockTransactionHash = blockInfo.blockTransactionsHash;
expect(blockInfo.height.lower).to.be.equal(1);
expect(blockInfo.height.higher).to.be.equal(0);
expect(blockInfo.timestamp.lower).to.be.equal(0);
expect(blockInfo.timestamp.higher).to.be.equal(0);

});
});

describe('getBlockTransactions', () => {
let nextId: string;
let firstId: string;

it('should return block transactions data given height', (done) => {
blockRepository.getBlockTransactions(UInt64.fromUint(1))
.subscribe((transactions) => {
nextId = transactions[0].transactionInfo!.id;
firstId = transactions[1].transactionInfo!.id;
expect(transactions.length).to.be.greaterThan(0);
done();
});
it('should return block transactions data given height', async () => {
const transactions = await blockRepository.getBlockTransactions(UInt64.fromUint(1)).toPromise();
nextId = transactions[0].transactionInfo!.id;
firstId = transactions[1].transactionInfo!.id;
expect(transactions.length).to.be.greaterThan(0);
});

it('should return block transactions data given height with paginated transactionId', (done) => {
blockRepository.getBlockTransactions(UInt64.fromUint(1), new QueryParams(10, nextId))
.subscribe((transactions) => {
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
expect(transactions.length).to.be.greaterThan(0);
done();
});
it('should return block transactions data given height with paginated transactionId', async () => {
const transactions = await blockRepository.getBlockTransactions(UInt64.fromUint(1), new QueryParams(10, nextId)).toPromise();
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
expect(transactions.length).to.be.greaterThan(0);
});
});

describe('getBlocksByHeightWithLimit', () => {
it('should return block info given height and limit', (done) => {
blockRepository.getBlocksByHeightWithLimit(chainHeight, 50)
.subscribe((blocksInfo) => {
expect(blocksInfo.length).to.be.greaterThan(0);
done();
});
it('should return block info given height and limit', async () => {
const blocksInfo = await blockRepository.getBlocksByHeightWithLimit(chainHeight, 50).toPromise();
expect(blocksInfo.length).to.be.greaterThan(0);
});
});
describe('getMerkleReceipts', () => {
it('should return Merkle Receipts', (done) => {
receiptRepository.getBlockReceipts(chainHeight).pipe(
it('should return Merkle Receipts', async () => {
const merkleReceipts = await receiptRepository.getBlockReceipts(chainHeight).pipe(
mergeMap((_) => {
return receiptRepository.getMerkleReceipts(chainHeight, _.transactionStatements[0].generateHash());
}))
.subscribe((merkleReceipts) => {
expect(merkleReceipts.merklePath).not.to.be.null;
done();
});
})).toPromise();
expect(merkleReceipts.merklePath).not.to.be.null;
});
});
describe('getMerkleTransaction', () => {
it('should return Merkle Transaction', (done) => {
blockRepository.getBlockTransactions(chainHeight).pipe(
it('should return Merkle Transaction', async () => {
const merkleTransactionss = await blockRepository.getBlockTransactions(chainHeight).pipe(
mergeMap((_) => {
const hash = (_[0].transactionInfo as TransactionInfo).hash;
if (hash) {
return blockRepository.getMerkleTransaction(chainHeight, hash);
}
// If reaching this line, something is not right
throw new Error('Tansacation hash is undefined');
}))
.subscribe((merkleTransactionss) => {
expect(merkleTransactionss.merklePath).not.to.be.null;
done();
});
})).toPromise();
expect(merkleTransactionss.merklePath).not.to.be.null;
});
});

describe('getBlockReceipts', () => {
it('should return block receipts', (done) => {
receiptRepository.getBlockReceipts(chainHeight)
.subscribe((statement) => {
expect(statement.transactionStatements).not.to.be.null;
expect(statement.transactionStatements.length).to.be.greaterThan(0);
done();
});
it('should return block receipts', async () => {
const statement = await receiptRepository.getBlockReceipts(chainHeight).toPromise();
expect(statement.transactionStatements).not.to.be.null;
expect(statement.transactionStatements.length).to.be.greaterThan(0);
});
});
});
22 changes: 8 additions & 14 deletions e2e/infrastructure/ChainHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,18 @@ describe('ChainHttp', () => {
});

describe('getBlockchainHeight', () => {
it('should return blockchain height', (done) => {
chainRepository.getBlockchainHeight()
.subscribe((height) => {
expect(height.lower).to.be.greaterThan(0);
done();
});
it('should return blockchain height', async () => {
const height = await chainRepository.getBlockchainHeight().toPromise();
expect(height.lower).to.be.greaterThan(0);
});
});

describe('getBlockchainScore', () => {
it('should return blockchain score', (done) => {
chainRepository.getChainScore()
.subscribe((blockchainScore) => {
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
done();
});
it('should return blockchain score', async () => {
const blockchainScore = await chainRepository.getChainScore().toPromise();
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
});
});
});
24 changes: 9 additions & 15 deletions e2e/infrastructure/DiagnosticHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@ describe('DiagnosticHttp', () => {
});

describe('getDiagnosticStorage', () => {
it('should return diagnostic storage', (done) => {
diagnosticRepository.getDiagnosticStorage()
.subscribe((blockchainStorageInfo) => {
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
done();
});
it('should return diagnostic storage', async () => {
const blockchainStorageInfo = await diagnosticRepository.getDiagnosticStorage().toPromise();
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
});
});

describe('getServerInfo', () => {
it('should return diagnostic storage', (done) => {
diagnosticRepository.getServerInfo()
.subscribe((serverInfo) => {
expect(serverInfo.restVersion).not.to.be.null;
expect(serverInfo.sdkVersion).not.to.be.null;
done();
});
it('should return diagnostic storage', async () => {
const serverInfo = await diagnosticRepository.getServerInfo().toPromise();
expect(serverInfo.restVersion).not.to.be.null;
expect(serverInfo.sdkVersion).not.to.be.null;
});
});
});
9 changes: 5 additions & 4 deletions e2e/infrastructure/IntegrationTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ export class IntegrationTestHelper {
// What would be the best maxFee? In the future we will load the fee multiplier from rest.
this.maxFee = UInt64.fromUint(1000000);

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