Skip to content

Commit

Permalink
Merge 9ebd91d into 2764846
Browse files Browse the repository at this point in the history
  • Loading branch information
fboucquez committed Nov 22, 2020
2 parents 2764846 + 9ebd91d commit 0d9e2ee
Show file tree
Hide file tree
Showing 48 changed files with 1,394 additions and 808 deletions.
2 changes: 1 addition & 1 deletion e2e/infrastructure/AccountHttp.spec.ts
Expand Up @@ -167,7 +167,7 @@ describe('AccountHttp', () => {
const accountInfo = await accountRepository.getAccountInfo(accountAddress).toPromise();
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);

const merkleInfo = await accountRepository.getAccountsInfoMerkle(accountInfo.address).toPromise();
const merkleInfo = await accountRepository.getAccountInfoMerkle(accountInfo.address).toPromise();
expect(merkleInfo.raw).to.not.be.undefined;
});
});
Expand Down
4 changes: 3 additions & 1 deletion e2e/infrastructure/IntegrationTestHelper.ts
Expand Up @@ -65,7 +65,9 @@ export class IntegrationTestHelper {
return this.toAccounts(configResult.addresses);
}
private async loadBootstrap(): Promise<{ accounts: string[]; apiUrl: string; addresses: Addresses }> {
const target = process.env.REST_DEV ? '../catapult-rest/rest/target' : 'target/bootstrap-test';
// const target = 'target/bootstrap-test';
const target = '../symbol-bootstrap/target/bootstrap';
// const target = '../catapult-rest/rest/target';
console.log('Loading bootstrap server');
const addresses = BootstrapUtils.loadExistingAddresses(target);
return this.toAccounts(addresses);
Expand Down
38 changes: 19 additions & 19 deletions e2e/infrastructure/RestrictionHttp.spec.ts
Expand Up @@ -16,25 +16,25 @@

import { deepEqual } from 'assert';
import { expect } from 'chai';
import { RestrictionAccountRepository } from '../../src/infrastructure/RestrictionAccountRepository';
import { RestrictionMosaicRepository } from '../../src/infrastructure/RestrictionMosaicRepository';
import { Account } from '../../src/model/account/Account';
import { Address } from '../../src/model/account/Address';
import { MosaicFlags } from '../../src/model/mosaic/MosaicFlags';
import { MosaicId } from '../../src/model/mosaic/MosaicId';
import { MosaicNonce } from '../../src/model/mosaic/MosaicNonce';
import { NetworkType } from '../../src/model/network/NetworkType';
import { AddressRestrictionFlag } from '../../src/model/restriction/AddressRestrictionFlag';
import { MosaicAddressRestriction } from '../../src/model/restriction/MosaicAddressRestriction';
import { MosaicRestrictionEntryType } from '../../src/model/restriction/MosaicRestrictionEntryType';
import { MosaicRestrictionType } from '../../src/model/restriction/MosaicRestrictionType';
import { AccountRestrictionTransaction } from '../../src/model/transaction/AccountRestrictionTransaction';
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
import { Deadline } from '../../src/model/transaction/Deadline';
import { MosaicAddressRestrictionTransaction } from '../../src/model/transaction/MosaicAddressRestrictionTransaction';
import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction';
import { MosaicGlobalRestrictionTransaction } from '../../src/model/transaction/MosaicGlobalRestrictionTransaction';
import { UInt64 } from '../../src/model/UInt64';
import { RestrictionAccountRepository, RestrictionMosaicRepository } from '../../src/infrastructure';
import { UInt64 } from '../../src/model';
import { Account, Address } from '../../src/model/account';
import { MosaicFlags, MosaicId, MosaicNonce } from '../../src/model/mosaic';
import { NetworkType } from '../../src/model/network';
import {
AddressRestrictionFlag,
MosaicAddressRestriction,
MosaicRestrictionEntryType,
MosaicRestrictionType,
} from '../../src/model/restriction';
import {
AccountRestrictionTransaction,
AggregateTransaction,
Deadline,
MosaicAddressRestrictionTransaction,
MosaicDefinitionTransaction,
MosaicGlobalRestrictionTransaction,
} from '../../src/model/transaction';
import { IntegrationTestHelper } from './IntegrationTestHelper';

describe('RestrictionHttp', () => {
Expand Down
34 changes: 32 additions & 2 deletions e2e/infrastructure/TransactionHttp.spec.ts
Expand Up @@ -33,7 +33,7 @@ import {
TransactionStatusRepository,
} from '../../src/infrastructure';
import { TransactionPaginationStreamer } from '../../src/infrastructure/paginationStreamer';
import { UInt64 } from '../../src/model';
import { TransactionVersion, UInt64, VotingKeyLinkV1Transaction } from '../../src/model';
import { Account } from '../../src/model/account';
import { LockHashAlgorithm } from '../../src/model/lock';
import { PlainMessage } from '../../src/model/message';
Expand Down Expand Up @@ -102,6 +102,7 @@ describe('TransactionHttp', () => {
let transactionRepository: TransactionRepository;
let transactionStatusRepository: TransactionStatusRepository;
let votingKey: string;
let votingKeyV1: string;

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

Expand All @@ -115,7 +116,8 @@ describe('TransactionHttp', () => {
harvestingAccount = helper.harvestingAccount;
generationHash = helper.generationHash;
networkType = helper.networkType;
votingKey = Convert.uint8ToHex(Crypto.randomBytes(48));
votingKey = Convert.uint8ToHex(Crypto.randomBytes(32));
votingKeyV1 = Convert.uint8ToHex(Crypto.randomBytes(48));
namespaceRepository = helper.repositoryFactory.createNamespaceRepository();
transactionRepository = helper.repositoryFactory.createTransactionRepository();
transactionStatusRepository = helper.repositoryFactory.createTransactionStatusRepository();
Expand Down Expand Up @@ -735,10 +737,12 @@ describe('TransactionHttp', () => {
300,
LinkAction.Link,
networkType,
TransactionVersion.VOTING_KEY_LINK_V2,
helper.maxFee,
);
const signedTransaction = votingLinkTransaction.signWith(account, generationHash);

console.log(signedTransaction.payload);
return helper.announce(signedTransaction).then((transaction: VotingKeyLinkTransaction) => {
expect(transaction.linkedPublicKey, 'LinkedPublicKey').not.to.be.undefined;
expect(transaction.startEpoch, 'startEpoch').not.to.be.undefined;
Expand All @@ -748,6 +752,31 @@ describe('TransactionHttp', () => {
});
});
});

describe('VotingKeyLinkV1Transaction', () => {
it('standalone', () => {
const votingLinkTransaction = VotingKeyLinkV1Transaction.create(
Deadline.create(helper.epochAdjustment),
votingKeyV1,
100,
300,
LinkAction.Link,
networkType,
helper.maxFee,
);
const signedTransaction = votingLinkTransaction.signWith(account, generationHash);

console.log(signedTransaction.payload);

return helper.announce(signedTransaction).then((transaction: VotingKeyLinkV1Transaction) => {
expect(transaction.linkedPublicKey, 'LinkedPublicKey').not.to.be.undefined;
expect(transaction.startEpoch, 'startEpoch').not.to.be.undefined;
expect(transaction.endEpoch, 'endEpoch').not.to.be.undefined;
expect(transaction.linkAction, 'LinkAction').not.to.be.undefined;
return signedTransaction;
});
});
});
describe('VotingKeyLinkTransaction', () => {
it('aggregate', () => {
const votingLinkTransaction = VotingKeyLinkTransaction.create(
Expand All @@ -757,6 +786,7 @@ describe('TransactionHttp', () => {
300,
LinkAction.Unlink,
networkType,
TransactionVersion.VOTING_KEY_LINK_V2,
helper.maxFee,
);
const aggregateTransaction = AggregateTransaction.createComplete(
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -99,7 +99,7 @@
"dependencies": {
"@js-joda/core": "^3.2.0",
"bluebird": "^3.7.2",
"catbuffer-typescript": "0.0.24-alpha-202011091145",
"catbuffer-typescript": "0.0.24-alpha-202011210642",
"crypto-js": "^4.0.0",
"diff": "^4.0.2",
"futoin-hkdf": "^1.3.2",
Expand Down
18 changes: 17 additions & 1 deletion src/core/format/Convert.ts
Expand Up @@ -34,9 +34,10 @@ export class Convert {
/**
* Determines whether or not a string is a hex string.
* @param {string} input The string to test.
* @param {string} expectedSize the expected size of the input
* @returns {boolean} true if the input is a hex string, false otherwise.
*/
public static isHexString = (input: string): boolean => {
public static isHexString = (input: string, expectedSize = 0): boolean => {
if (0 !== input.length % 2) {
return false;
}
Expand All @@ -45,9 +46,24 @@ export class Convert {
return false;
}
}
if (expectedSize && expectedSize !== input.length) {
return false;
}
return true;
};

/**
* Validates if a string is a valid hex of the expected size.
* @param {string} input The string to test.
* @param {string} expectedSize the expected size of the input
* @param {string} message error message.
*/
public static validateHexString = (input: string, expectedSize: number, message: string): void => {
if (!Convert.isHexString(input, expectedSize)) {
throw new Error(`${message}. Value ${input} is not an hex string of size ${expectedSize}.`);
}
};

/**
* Converts a hex string to a uint8 array.
* @param {string} input A hex encoded string.
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/AccountHttp.ts
Expand Up @@ -93,7 +93,7 @@ export class AccountHttp extends Http implements AccountRepository {
*
* @param address the address
*/
getAccountsInfoMerkle(address: Address): Observable<MerkleStateInfo> {
getAccountInfoMerkle(address: Address): Observable<MerkleStateInfo> {
return this.call(this.accountRoutesApi.getAccountInfoMerkle(address.plain()), DtoMapping.toMerkleStateInfo);
}

Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/AccountRepository.ts
Expand Up @@ -45,5 +45,5 @@ export interface AccountRepository extends Searcher<AccountInfo, AccountSearchCr
* @param address Address
* @returns Observable<MerkleStateInfo>
*/
getAccountsInfoMerkle(address: Address): Observable<MerkleStateInfo>;
getAccountInfoMerkle(address: Address): Observable<MerkleStateInfo>;
}
4 changes: 2 additions & 2 deletions src/infrastructure/RestrictionAccountRepository.ts
Expand Up @@ -19,9 +19,9 @@ import { Address } from '../model/account/Address';
import { MerkleStateInfo } from '../model/blockchain';
import { AccountRestrictions } from '../model/restriction';
import { Searcher } from './paginationStreamer';
import { RestrictionMosaicSearchCriteria } from './searchCriteria';
import { RestrictionAccountSearchCriteria } from './searchCriteria';

export interface RestrictionAccountRepository extends Searcher<AccountRestrictions, RestrictionMosaicSearchCriteria> {
export interface RestrictionAccountRepository extends Searcher<AccountRestrictions, RestrictionAccountSearchCriteria> {
/**
* Gets Account restrictions.
* @param address the address
Expand Down
9 changes: 3 additions & 6 deletions src/infrastructure/TransactionRepository.ts
Expand Up @@ -15,12 +15,9 @@
*/

import { Observable } from 'rxjs';
import { CosignatureSignedTransaction } from '../model/transaction/CosignatureSignedTransaction';
import { SignedTransaction } from '../model/transaction/SignedTransaction';
import { Transaction } from '../model/transaction/Transaction';
import { TransactionAnnounceResponse } from '../model/transaction/TransactionAnnounceResponse';
import { Searcher } from './paginationStreamer/Searcher';
import { TransactionSearchCriteria } from './searchCriteria/TransactionSearchCriteria';
import { CosignatureSignedTransaction, SignedTransaction, Transaction, TransactionAnnounceResponse } from '../model/transaction';
import { Searcher } from './paginationStreamer';
import { TransactionSearchCriteria } from './searchCriteria';
import { TransactionGroup } from './TransactionGroup';

/**
Expand Down

0 comments on commit 0d9e2ee

Please sign in to comment.