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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
---|---|---
SDK Core| v0.21.1 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
Catbuffer | v0.0.22 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
Client Library | v0.10.0-3 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)
Client Library | v0.10.1 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)

- **[BREAKING CHANGE]** `Deadline.create` requires the configurable `epochAdjustment` from the network properties.
- **[BREAKING CHANGE]** `NetworkCurrency` subclasses replaced with `Currency` objects.
- **[BREAKING CHANGE]** `SecreatLockRepository.getSecretLock` has been removed. You can now search by secret by using the search criteria.
- Added `FinalizationRepository`.
- Added `transferMosaicId`, `fromTransferAmount`, `toTransferAmount` to transaction searches.
- Added `CurrencyService` to allow loading Network and custom `Currency` objects from the rest service.
- Added `UnlockedAccount` endpoint in `NodeRepository` for checking delegated harvesting status.

## [0.21.0] - 25-Sep-2020

Expand Down
1 change: 1 addition & 0 deletions e2e/e2e-preset.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nemesis:
mosaics:
- accounts: 10
symbolRestImage: symbolplatform/symbol-rest:2.1.1-alpha
58 changes: 58 additions & 0 deletions e2e/infrastructure/FinalizationHttp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2018 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { expect } from 'chai';
import { FinalizationRepository } from '../../src/infrastructure/FinalizationRepository';
import { UInt64 } from '../../src/model/UInt64';
import { IntegrationTestHelper } from './IntegrationTestHelper';

describe('FinalizationHttp', () => {
let finalizationRepository: FinalizationRepository;
const helper = new IntegrationTestHelper();

before(() => {
return helper.start({ openListener: false }).then(() => {
finalizationRepository = helper.repositoryFactory.createFinalizationRepository();
});
});

after(() => {
return helper.close();
});

describe('getFinalizationProofAtEpoch', () => {
it('should return finalization proof at epoch', async () => {
const dto = await finalizationRepository.getFinalizationProofAtEpoch(1).toPromise();
expect(dto).not.to.be.null;
expect(dto.height).to.deep.eq(UInt64.fromUint(1));
expect(dto.version).to.eq(1);
expect(dto.finalizationEpoch).to.eq(1);
expect(dto.finalizationPoint).to.eq(1);
expect(dto.hash).not.to.be.null;
});
});

describe('getNetworkName', () => {
it('should return finalization proof at height', async () => {
const dto = await finalizationRepository.getFinalizationProofAtHeight(UInt64.fromUint(1)).toPromise();
expect(dto).not.to.be.null;
expect(dto.height).to.deep.eq(UInt64.fromUint(1));
expect(dto.version).to.eq(1);
expect(dto.finalizationEpoch).to.eq(1);
expect(dto.finalizationPoint).to.eq(1);
expect(dto.hash).not.to.be.null;
});
});
});
8 changes: 8 additions & 0 deletions e2e/infrastructure/NodeHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ describe('NodeHttp', () => {
expect(health.db).not.to.be.null;
});
});

describe('getUnlockedAccount', () => {
it('should return unlocked account', async () => {
const unlockedAccount = await nodeRepository.getUnlockedAccount().toPromise();
expect(unlockedAccount).not.to.be.null;
expect(unlockedAccount.length).greaterThan(0);
});
});
});
16 changes: 13 additions & 3 deletions e2e/infrastructure/SecretLockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ describe('SecretLockHttp', () => {
* =========================
*/

describe('getSecretLock', () => {
describe('searchSecretLock using secret', () => {
it('should return hash lock info given hash', async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
const info = await SecretLockRepo.getSecretLock(secret).toPromise();

const page = await SecretLockRepo.search({ address: account.address, secret }).toPromise();
expect(page.data.length).eq(1);
expect(page.pageNumber).eq(1);

const info = page.data[0];
expect(info.ownerAddress.plain()).to.be.equal(account.address.plain());
expect(info.recipientAddress.plain()).to.be.equal(account2.address.plain());
expect(info.amount.toString()).to.be.equal('10');
Expand All @@ -106,7 +111,12 @@ describe('SecretLockHttp', () => {
.search({ address: account.address, pageSize: 20, order: Order.Asc })
.pipe(take(20), toArray())
.toPromise();
const info = await SecretLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }).toPromise();
const info = await SecretLockRepo.search({
address: account.address,
secret: undefined,
pageSize: 20,
order: Order.Asc,
}).toPromise();
expect(infoStreamer.length).to.be.greaterThan(0);
deepEqual(infoStreamer[0], info.data[0]);
});
Expand Down
229 changes: 229 additions & 0 deletions e2e/infrastructure/TransactionSearch.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
/*
* Copyright 2020 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { deepEqual } from 'assert';
import { expect } from 'chai';
import { first, take, toArray } from 'rxjs/operators';
import { TransactionPaginationStreamer } from '../../src/infrastructure/paginationStreamer/TransactionPaginationStreamer';
import { TransactionSearchCriteria } from '../../src/infrastructure/searchCriteria/TransactionSearchCriteria';
import { TransactionGroup } from '../../src/infrastructure/TransactionGroup';
import { TransactionType } from '../../src/model/transaction/TransactionType';
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
import { UInt64 } from '../../src/model/UInt64';
import { IntegrationTestHelper } from './IntegrationTestHelper';

describe('TransactionSearch', () => {
const helper = new IntegrationTestHelper();

before(() => {
return helper.start({ openListener: false });
});

after(() => {
return helper.close();
});

describe('searchTransactions', () => {
it('should return transaction info given address', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const account = helper.account;
const transactions = await transactionRepository
.search({ group: TransactionGroup.Confirmed, address: account.address } as TransactionSearchCriteria)
.toPromise();
expect(transactions.data.length).to.be.greaterThan(0);
});
it('should return transaction info given height all types', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const transactions = await transactionRepository
.search({ group: TransactionGroup.Confirmed, height: UInt64.fromUint(1) } 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.be.greaterThan(0);
});

it('should return transaction info given height and namesapce, mosaic types', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
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);
});
});

describe('searchTransactions using steamer', () => {
it('should return transaction info given address', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const streamer = new TransactionPaginationStreamer(transactionRepository);
const account = helper.account;
const transactionsNoStreamer = await transactionRepository
.search({ group: TransactionGroup.Confirmed, address: account.address, pageSize: 10 } as TransactionSearchCriteria)
.toPromise();
const transactions = await streamer
.search({ group: TransactionGroup.Confirmed, address: account.address, pageSize: 10 })
.pipe(take(10), toArray())
.toPromise();
expect(transactions.length).to.be.greaterThan(0);
deepEqual(transactionsNoStreamer.data, transactions);
});

it('should return transaction info given mosaic id', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const streamer = new TransactionPaginationStreamer(transactionRepository);

const transferTransaction = (await streamer
.search({
embedded: true,
group: TransactionGroup.Confirmed,
type: [TransactionType.TRANSFER],
})
.pipe(first())
.toPromise()) as TransferTransaction;
const mosaicId = transferTransaction.mosaics[0].id;

const criteria: TransactionSearchCriteria = {
group: TransactionGroup.Confirmed,
pageSize: 10,
embedded: true,
transferMosaicId: mosaicId,
};

const transactions = await streamer.search(criteria).pipe(toArray()).toPromise();
expect(transactions.length).to.be.greaterThan(0);

transactions.forEach((t) => {
const mosaicIds = (t as TransferTransaction).mosaics.map((m) => m.id.toHex());
expect(mosaicIds.indexOf(mosaicId.toHex())).to.be.greaterThan(-1);
});
});

it('should return transaction info given mosaic id and from/to amount', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const streamer = new TransactionPaginationStreamer(transactionRepository);

const transferTransaction = (await streamer
.search({
embedded: true,
group: TransactionGroup.Confirmed,
type: [TransactionType.TRANSFER],
})
.pipe(first())
.toPromise()) as TransferTransaction;
const mosaic = transferTransaction.mosaics[0];
const mosaicId = mosaic.id;

const criteria: TransactionSearchCriteria = {
group: TransactionGroup.Confirmed,
fromTransferAmount: mosaic.amount,
toTransferAmount: mosaic.amount,
pageSize: 10,
embedded: true,
transferMosaicId: mosaicId,
};

const transactions = await streamer.search(criteria).pipe(toArray()).toPromise();
expect(transactions.length).to.be.greaterThan(0);

transactions.forEach((t) => {
const thisTransactionMosaic = (t as TransferTransaction).mosaics.filter((m) => m.id.equals(mosaicId))[0];
expect(thisTransactionMosaic.id).deep.eq(mosaicId);
expect(thisTransactionMosaic.amount).deep.eq(mosaic.amount);
});
});

it('should return transaction info given mosaic id and from amount', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const streamer = new TransactionPaginationStreamer(transactionRepository);

const transferTransaction = (await streamer
.search({
embedded: true,
group: TransactionGroup.Confirmed,
type: [TransactionType.TRANSFER],
})
.pipe(first())
.toPromise()) as TransferTransaction;
const mosaic = transferTransaction.mosaics[0];
const mosaicId = mosaic.id;

const criteria: TransactionSearchCriteria = {
group: TransactionGroup.Confirmed,
fromTransferAmount: mosaic.amount,
pageSize: 10,
embedded: true,
transferMosaicId: mosaicId,
};

const transactions = await streamer.search(criteria).pipe(toArray()).toPromise();
expect(transactions.length).to.be.greaterThan(0);

transactions.forEach((t) => {
const thisTransactionMosaic = (t as TransferTransaction).mosaics.filter((m) => m.id.equals(mosaicId))[0];
expect(thisTransactionMosaic.id).deep.eq(mosaicId);
expect(thisTransactionMosaic.amount.compare(mosaic.amount)).to.be.greaterThan(-1);
});
});

it('should return transaction info given mosaic id and to amount', async () => {
const transactionRepository = helper.repositoryFactory.createTransactionRepository();
const streamer = new TransactionPaginationStreamer(transactionRepository);

const transferTransaction = (await streamer
.search({
embedded: true,
group: TransactionGroup.Confirmed,
type: [TransactionType.TRANSFER],
})
.pipe(first())
.toPromise()) as TransferTransaction;
const mosaic = transferTransaction.mosaics[0];
const mosaicId = mosaic.id;

const criteria: TransactionSearchCriteria = {
group: TransactionGroup.Confirmed,
toTransferAmount: mosaic.amount,
pageSize: 10,
embedded: true,
transferMosaicId: mosaicId,
};

const transactions = await streamer.search(criteria).pipe(toArray()).toPromise();
expect(transactions.length).to.be.greaterThan(0);

transactions.forEach((t) => {
const thisTransactionMosaic = (t as TransferTransaction).mosaics.filter((m) => m.id.equals(mosaicId))[0];
expect(thisTransactionMosaic.id).deep.eq(mosaicId);
expect(thisTransactionMosaic.amount.compare(mosaic.amount)).to.be.lessThan(1);
});
});
});
});
Loading