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
5 changes: 3 additions & 2 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { expect } from 'chai';
import { AccountRepository } from '../../src/infrastructure/AccountRepository';
import { MultisigRepository } from '../../src/infrastructure/MultisigRepository';
import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository';
import { RepositoryCallError } from '../../src/infrastructure/RepositoryCallError';
import { Account } from '../../src/model/account/Account';
import { Address } from '../../src/model/account/Address';
import { PlainMessage } from '../../src/model/message/PlainMessage';
Expand Down Expand Up @@ -187,9 +188,9 @@ describe('AccountHttp', () => {
return Promise.reject('should fail!');
},
(err) => {
const error = JSON.parse(err.message);
const error: RepositoryCallError = JSON.parse(err.message);
expect(error.statusCode).to.be.eq(404);
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
expect(error.statusMessage).to.be.eq('Not Found');
return Promise.resolve();
},
);
Expand Down
12 changes: 6 additions & 6 deletions e2e/infrastructure/IntegrationTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import { TransactionService } from '../../src/service/TransactionService';
import { NetworkCurrencyPublic } from '../../src/model/mosaic/NetworkCurrencyPublic';
import { NetworkCurrencyLocal } from '../../src/model/mosaic/NetworkCurrencyLocal';
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
import * as yaml from 'js-yaml';
import * as path from 'path';
import * as fs from 'fs';

export class IntegrationTestHelper {
public readonly yaml = require('js-yaml');
public apiUrl: string;
public repositoryFactory: RepositoryFactory;
public account: Account;
Expand All @@ -51,9 +53,7 @@ export class IntegrationTestHelper {

start(): Promise<IntegrationTestHelper> {
return new Promise<IntegrationTestHelper>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
require('fs').readFile(path.resolve(__dirname, '../conf/network.conf'), (err, jsonData) => {
fs.readFile(path.resolve(__dirname, '../conf/network.conf'), (err, jsonData: any) => {
if (err) {
return reject(err);
}
Expand Down Expand Up @@ -94,15 +94,15 @@ export class IntegrationTestHelper {
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) => {
fs.readFile(bootstrapPath, (error: any, yamlData: any) => {
if (error) {
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);
const parsedYaml = yaml.safeLoad(yamlData);
this.account = this.createAccount(parsedYaml.nemesis_addresses[0]);
this.account2 = this.createAccount(parsedYaml.nemesis_addresses[1]);
this.account3 = this.createAccount(parsedYaml.nemesis_addresses[2]);
Expand Down
1 change: 1 addition & 0 deletions e2e/infrastructure/MetadataHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ describe('MetadataHttp', () => {

describe('getNamespaceMetadata', () => {
it('should return metadata given a namespaceId', async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
const metadata = await metadataRepository.getNamespaceMetadata(namespaceId).toPromise();
expect(metadata.length).to.be.greaterThan(0);
expect(metadata[0].metadataEntry.scopedMetadataKey.toString()).to.be.equal('6');
Expand Down
57 changes: 42 additions & 15 deletions e2e/infrastructure/TransactionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ import { MosaicRestrictionFlag } from '../../src/model/restriction/MosaicRestric
import { OperationRestrictionFlag } from '../../src/model/restriction/OperationRestrictionFlag';
import { TransactionGroup } from '../../src/infrastructure/TransactionGroup';
import { TransactionStatusRepository } from '../../src/infrastructure/TransactionStatusRepository';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const CryptoJS = require('crypto-js');
import * as ripemd160 from 'ripemd160';
import { sha256 } from 'js-sha256';
import * as secureRandom from 'secure-random';
import * as CryptoJS from 'crypto-js';

describe('TransactionHttp', () => {
let transactionHash: string;
Expand All @@ -101,12 +102,6 @@ describe('TransactionHttp', () => {
let transactionRepository: TransactionRepository;
let transactionStatusRepository: TransactionStatusRepository;
let votingKey: string;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const secureRandom = require('secure-random');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sha256 = require('js-sha256');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ripemd160 = require('ripemd160');

const remoteAccount = Account.generateNewAccount(helper.networkType);

Expand Down Expand Up @@ -737,6 +732,8 @@ describe('TransactionHttp', () => {
const votingLinkTransaction = VotingKeyLinkTransaction.create(
Deadline.create(),
votingKey,
UInt64.fromUint(100),
UInt64.fromUint(300),
LinkAction.Link,
networkType,
helper.maxFee,
Expand All @@ -745,6 +742,8 @@ describe('TransactionHttp', () => {

return helper.announce(signedTransaction).then((transaction: VotingKeyLinkTransaction) => {
expect(transaction.linkedPublicKey, 'LinkedPublicKey').not.to.be.undefined;
expect(transaction.startPoint, 'StartPoint').not.to.be.undefined;
expect(transaction.endPoint, 'EndPoint').not.to.be.undefined;
expect(transaction.linkAction, 'LinkAction').not.to.be.undefined;
return signedTransaction;
});
Expand All @@ -755,6 +754,8 @@ describe('TransactionHttp', () => {
const votingLinkTransaction = VotingKeyLinkTransaction.create(
Deadline.create(),
votingKey,
UInt64.fromUint(100),
UInt64.fromUint(300),
LinkAction.Unlink,
networkType,
helper.maxFee,
Expand Down Expand Up @@ -1402,13 +1403,13 @@ describe('TransactionHttp', () => {

describe('getTransactionsById', () => {
it('should return transaction info given array of transactionHash', async () => {
const transactions = await transactionRepository.getTransactionsById([transactionHash]).toPromise();
const transactions = await transactionRepository.getTransactionsById([transactionHash], TransactionGroup.Confirmed).toPromise();
expect(transactions[0].transactionInfo!.hash).to.be.equal(transactionHash);
expect(transactions[0].transactionInfo!.id).to.be.equal(transactionId);
});

it('should return transaction info given array of transactionId', async () => {
const transactions = await transactionRepository.getTransactionsById([transactionId]).toPromise();
const transactions = await transactionRepository.getTransactionsById([transactionId], TransactionGroup.Confirmed).toPromise();
expect(transactions[0].transactionInfo!.hash).to.be.equal(transactionHash);
expect(transactions[0].transactionInfo!.id).to.be.equal(transactionId);
});
Expand Down Expand Up @@ -1468,15 +1469,15 @@ describe('TransactionHttp', () => {
);
const signedTransaction = aggregateTransaction.signWith(cosignAccount1, generationHash);
const transactionAnnounceResponse = await transactionRepository.announceAggregateBonded(signedTransaction).toPromise();
expect(transactionAnnounceResponse.message).to.be.equal('packet 500 was pushed to the network via /transactions/partial');
expect(transactionAnnounceResponse.message).to.be.equal('packet 256 was pushed to the network via /transactions/partial');
});
});

describe('announceAggregateBondedCosignature', () => {
it('should return success when announceAggregateBondedCosignature', async () => {
const payload = new CosignatureSignedTransaction('', '', '');
const transactionAnnounceResponse = await transactionRepository.announceAggregateBondedCosignature(payload).toPromise();
expect(transactionAnnounceResponse.message).to.be.equal('packet 501 was pushed to the network via /transactions/cosignature');
expect(transactionAnnounceResponse.message).to.be.equal('packet 257 was pushed to the network via /transactions/cosignature');
});
});

Expand All @@ -1495,11 +1496,37 @@ describe('TransactionHttp', () => {
.toPromise();
expect(transactions.data.length).to.be.greaterThan(0);
});
it('should return transaction info given height', async () => {
it('should return transaction info given height all types', async () => {
const transactions = await transactionRepository
.search({ group: TransactionGroup.Confirmed, height: UInt64.fromUint(1) } as TransactionSearchCriteria)
.toPromise();
expect(transactions.data.length).to.be.greaterThan(0);

const mosaicDefinitions = transactions.data.filter((t) => t.type == TransactionType.MOSAIC_DEFINITION).length;
const namespaceRegistration = transactions.data.filter((t) => t.type == TransactionType.NAMESPACE_REGISTRATION).length;
const others = transactions.data.filter(
(t) => t.type !== TransactionType.NAMESPACE_REGISTRATION && t.type !== TransactionType.MOSAIC_DEFINITION,
).length;
expect(mosaicDefinitions).to.be.greaterThan(0);
expect(namespaceRegistration).to.be.greaterThan(0);
expect(others).to.be.greaterThan(0);
});

it('should return transaction info given height and namesapce, mosaic types', async () => {
const transactions = await transactionRepository
.search({
group: TransactionGroup.Confirmed,
height: UInt64.fromUint(1),
type: [TransactionType.MOSAIC_DEFINITION, TransactionType.NAMESPACE_REGISTRATION],
} as TransactionSearchCriteria)
.toPromise();
const mosaicDefinitions = transactions.data.filter((t) => t.type == TransactionType.MOSAIC_DEFINITION).length;
const namespaceRegistration = transactions.data.filter((t) => t.type == TransactionType.NAMESPACE_REGISTRATION).length;
const others = transactions.data.filter(
(t) => t.type !== TransactionType.NAMESPACE_REGISTRATION && t.type !== TransactionType.MOSAIC_DEFINITION,
).length;
expect(mosaicDefinitions).to.be.greaterThan(0);
expect(namespaceRegistration).to.be.greaterThan(0);
expect(others).to.eq(0);
});
});

Expand Down
Loading