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
11 changes: 4 additions & 7 deletions e2e/infrastructure/PersistentHarvesting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { AccountKeyLinkTransaction } from '../../src/model/transaction/AccountKe
import { PersistentDelegationRequestTransaction } from '../../src/model/transaction/PersistentDelegationRequestTransaction';
import { VrfKeyLinkTransaction } from '../../src/model/transaction/VrfKeyLinkTransaction';
import { NodeKeyLinkTransaction } from '../../src/model/transaction/NodeKeyLinkTransaction';
import { Duration } from 'js-joda';

describe('PersistentHarvesting', () => {
const helper = new IntegrationTestHelper();
Expand All @@ -32,8 +31,6 @@ describe('PersistentHarvesting', () => {
let networkType: NetworkType;
let remoteAccount: Account;

const epochAdjustment = Duration.ofSeconds(1573430400);

const vrfKeyPair = Account.createFromPrivateKey(
'82798EA9A2D2D202AFCCC82C40A287780BCA3C7F7A2FD5B754832804C6BE1BAA',
NetworkType.MIJIN_TEST,
Expand Down Expand Up @@ -62,7 +59,7 @@ describe('PersistentHarvesting', () => {
describe('AccountKeyLinkTransaction', () => {
it('standalone', () => {
const accountLinkTransaction = AccountKeyLinkTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
remoteAccount.publicKey,
LinkAction.Link,
networkType,
Expand All @@ -77,7 +74,7 @@ describe('PersistentHarvesting', () => {
describe('VrfKeyLinkTransaction', () => {
it('standalone', () => {
const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
vrfKeyPair.publicKey,
LinkAction.Link,
networkType,
Expand All @@ -92,7 +89,7 @@ describe('PersistentHarvesting', () => {
describe('NodeKeyLinkTransaction', () => {
it('standalone', () => {
const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db',
LinkAction.Link,
networkType,
Expand All @@ -112,7 +109,7 @@ describe('PersistentHarvesting', () => {
describe('transactions', () => {
it('should create delegated harvesting transaction', () => {
const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
remoteAccount.privateKey,
vrfKeyPair.privateKey,
'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db',
Expand Down
4 changes: 1 addition & 3 deletions e2e/infrastructure/SecretLockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { SecretLockTransaction } from '../../src/model/transaction/SecretLockTra
import { LockHashAlgorithm } from '../../src/model/lock/LockHashAlgorithm';
import { sha3_256 } from 'js-sha3';
import { Crypto } from '../../src/core/crypto';
import { Duration } from 'js-joda';

describe('SecretLockHttp', () => {
const helper = new IntegrationTestHelper();
Expand All @@ -38,7 +37,6 @@ describe('SecretLockHttp', () => {
let generationHash: string;
let networkType: NetworkType;
let secret: string;
const epochAdjustment = Duration.ofSeconds(1573430400);

before(() => {
return helper.start({ openListener: true }).then(() => {
Expand All @@ -64,7 +62,7 @@ describe('SecretLockHttp', () => {
describe('Create a hash lock', () => {
it('Announce SecretLockTransaction', () => {
const secretLockTransaction = SecretLockTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
helper.createNetworkCurrency(10, false),
UInt64.fromUint(100),
LockHashAlgorithm.Op_Sha3_256,
Expand Down
4 changes: 1 addition & 3 deletions e2e/service/AccountService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper';
import { AccountService } from '../../src/service/AccountService';
import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction';
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
import { Duration } from 'js-joda';

describe('AccountService', () => {
const helper = new IntegrationTestHelper();
Expand All @@ -33,7 +32,6 @@ describe('AccountService', () => {
let accountService: AccountService;
let namespaceId: NamespaceId;
const name = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
const epochAdjustment = Duration.ofSeconds(1573430400);

before(() => {
return helper.start({ openListener: true }).then(() => {
Expand All @@ -56,7 +54,7 @@ describe('AccountService', () => {
describe('Create a namespace', () => {
it('Announce NamespaceRegistrationTransaction', () => {
const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
name,
UInt64.fromUint(300000),
networkType,
Expand Down
16 changes: 13 additions & 3 deletions e2e/service/BlockService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { BlockService } from '../../src/service/BlockService';
import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper';
import { TransactionGroup } from '../../src/infrastructure/TransactionGroup';
import { TransactionStatement } from '../../src/model/receipt/TransactionStatement';
import { Duration } from 'js-joda';
import { BlockRepository } from '../../src/infrastructure/BlockRepository';

describe('BlockService', () => {
const helper = new IntegrationTestHelper();
Expand All @@ -40,7 +40,7 @@ describe('BlockService', () => {
let blockService: BlockService;
let transactionRepository: TransactionRepository;
let receiptRepository: ReceiptRepository;
const epochAdjustment = Duration.ofSeconds(1573430400);
let blockRepository: BlockRepository;

before(() => {
return helper.start({ openListener: true }).then(() => {
Expand All @@ -50,6 +50,7 @@ describe('BlockService', () => {
networkType = helper.networkType;
transactionRepository = helper.repositoryFactory.createTransactionRepository();
receiptRepository = helper.repositoryFactory.createReceiptRepository();
blockRepository = helper.repositoryFactory.createBlockRepository();
blockService = new BlockService(helper.repositoryFactory);
});
});
Expand All @@ -66,7 +67,7 @@ describe('BlockService', () => {
describe('Create a transfer', () => {
it('Announce TransferTransaction', () => {
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
account2.address,
[NetworkCurrencyLocal.createAbsolute(1)],
PlainMessage.create('test-message'),
Expand Down Expand Up @@ -107,4 +108,13 @@ describe('BlockService', () => {
expect(validationResult).to.be.true;
});
});

describe('Calculate merkler transaction root hash', () => {
it('Calculate merkler transaction root hash', async () => {
const calculated = await blockService.calculateTransactionsMerkleRootHash(UInt64.fromUint(1)).toPromise();
const block = await blockRepository.getBlockByHeight(UInt64.fromUint(1)).toPromise();
const rootHash = block.blockTransactionsHash;
expect(rootHash).to.be.equal(calculated);
});
});
});
36 changes: 17 additions & 19 deletions e2e/service/TransactionService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { assert, expect } from 'chai';
import { Duration } from 'js-joda';
import { Convert } from '../../src/core/format/Convert';
import { TransactionRepository } from '../../src/infrastructure/TransactionRepository';
import { Account } from '../../src/model/account/Account';
Expand Down Expand Up @@ -60,7 +59,6 @@ describe('TransactionService', () => {
let networkType: NetworkType;
let transactionService: TransactionService;
let transactionRepository: TransactionRepository;
const epochAdjustment = Duration.ofSeconds(1573430400);

before(() => {
return helper.start({ openListener: true }).then(() => {
Expand All @@ -86,7 +84,7 @@ describe('TransactionService', () => {

function buildAggregateTransaction(): AggregateTransaction {
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
addressAlias,
[NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))],
PlainMessage.create('test-message'),
Expand All @@ -95,7 +93,7 @@ describe('TransactionService', () => {
);
// Unlink MosaicAlias
const mosaicAliasTransactionUnlink = MosaicAliasTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
AliasAction.Unlink,
mosaicAlias,
mosaicId,
Expand All @@ -107,7 +105,7 @@ describe('TransactionService', () => {
const nonce = MosaicNonce.createRandom();
newMosaicId = MosaicId.createFromNonce(nonce, account.address);
const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
nonce,
newMosaicId,
MosaicFlags.create(true, true, false),
Expand All @@ -118,7 +116,7 @@ describe('TransactionService', () => {
);

const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
newMosaicId,
MosaicSupplyChangeAction.Increase,
UInt64.fromUint(200000),
Expand All @@ -128,7 +126,7 @@ describe('TransactionService', () => {

// Link namespace with new MosaicId
const mosaicAliasTransactionRelink = MosaicAliasTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
AliasAction.Link,
mosaicAlias,
newMosaicId,
Expand All @@ -138,7 +136,7 @@ describe('TransactionService', () => {

// Use new mosaicAlias in metadata
const mosaicMetadataTransaction = MosaicMetadataTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
account.address,
UInt64.fromUint(5),
mosaicAlias,
Expand All @@ -148,7 +146,7 @@ describe('TransactionService', () => {
helper.maxFee,
);
return AggregateTransaction.createComplete(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
[
transferTransaction.toAggregate(account.publicAccount),
mosaicAliasTransactionUnlink.toAggregate(account.publicAccount),
Expand All @@ -172,7 +170,7 @@ describe('TransactionService', () => {
it('Announce NamespaceRegistrationTransaction', () => {
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
namespaceName,
UInt64.fromUint(20),
networkType,
Expand All @@ -189,7 +187,7 @@ describe('TransactionService', () => {
it('Announce NamespaceRegistrationTransaction', () => {
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
namespaceName,
UInt64.fromUint(50),
networkType,
Expand All @@ -205,7 +203,7 @@ describe('TransactionService', () => {
describe('Setup test AddressAlias', () => {
it('Announce addressAliasTransaction', () => {
const addressAliasTransaction = AddressAliasTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
AliasAction.Link,
addressAlias,
account.address,
Expand All @@ -224,7 +222,7 @@ describe('TransactionService', () => {
const nonce = MosaicNonce.createRandom();
mosaicId = MosaicId.createFromNonce(nonce, account.address);
const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
nonce,
mosaicId,
MosaicFlags.create(true, true, false),
Expand All @@ -243,7 +241,7 @@ describe('TransactionService', () => {
describe('MosaicSupplyChangeTransaction', () => {
it('standalone', () => {
const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
mosaicId,
MosaicSupplyChangeAction.Increase,
UInt64.fromUint(200000),
Expand All @@ -259,7 +257,7 @@ describe('TransactionService', () => {
describe('Setup MosaicAlias', () => {
it('Announce MosaicAliasTransaction', () => {
const mosaicAliasTransaction = MosaicAliasTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
AliasAction.Link,
mosaicAlias,
mosaicId,
Expand All @@ -275,7 +273,7 @@ describe('TransactionService', () => {
describe('Create Transfer with alias', () => {
it('Announce TransferTransaction', () => {
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
addressAlias,
[NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))],
PlainMessage.create('test-message'),
Expand Down Expand Up @@ -313,7 +311,7 @@ describe('TransactionService', () => {
describe('Transfer mosaic to account 3', () => {
it('Announce TransferTransaction', () => {
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
account3.address,
[new Mosaic(mosaicAlias, UInt64.fromUint(1))],
PlainMessage.create('test-message'),
Expand All @@ -331,7 +329,7 @@ describe('TransactionService', () => {
const transactions: SignedTransaction[] = [];
// 1. Transfer A -> B
const transaction1 = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
account2.address,
[new Mosaic(mosaicAlias, UInt64.fromUint(1))],
PlainMessage.create('test-message'),
Expand All @@ -342,7 +340,7 @@ describe('TransactionService', () => {

// 2. Transfer C -> D
const transaction2 = TransferTransaction.create(
Deadline.create(epochAdjustment),
Deadline.create(helper.epochAdjustment),
cosignAccount4.address,
[new Mosaic(mosaicAlias, UInt64.fromUint(1))],
PlainMessage.create('test-message'),
Expand Down
Loading