diff --git a/e2e/infrastructure/AccountHttp.spec.ts b/e2e/infrastructure/AccountHttp.spec.ts index fdef41db23..10f7674927 100644 --- a/e2e/infrastructure/AccountHttp.spec.ts +++ b/e2e/infrastructure/AccountHttp.spec.ts @@ -38,6 +38,7 @@ import { toArray, take } from 'rxjs/operators'; import { deepEqual } from 'assert'; import { Order } from '../../src/infrastructure/infrastructure'; import { AccountOrderBy } from '../../src/infrastructure/searchCriteria/AccountOrderBy'; +import { Duration } from 'js-joda'; describe('AccountHttp', () => { const helper = new IntegrationTestHelper(); @@ -56,6 +57,8 @@ describe('AccountHttp', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -87,7 +90,7 @@ describe('AccountHttp', () => { describe('Make sure test account is not virgin', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -104,7 +107,7 @@ describe('AccountHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -119,7 +122,7 @@ describe('AccountHttp', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, account.address, @@ -134,7 +137,7 @@ describe('AccountHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -144,7 +147,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -249,7 +252,7 @@ describe('AccountHttp', () => { describe('Remove test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceId, account.address, @@ -264,7 +267,7 @@ describe('AccountHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, 0, [], @@ -273,7 +276,7 @@ describe('AccountHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 0, 0, [], @@ -283,7 +286,7 @@ describe('AccountHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, -1, [], @@ -293,7 +296,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/BlockHttp.spec.ts b/e2e/infrastructure/BlockHttp.spec.ts index a5ce3eaa7a..1ebadeefe5 100644 --- a/e2e/infrastructure/BlockHttp.spec.ts +++ b/e2e/infrastructure/BlockHttp.spec.ts @@ -31,6 +31,7 @@ import { take } from 'rxjs/operators'; import { TransactionStatement } from '../../src/model/model'; import { ReceiptPaginationStreamer } from '../../src/infrastructure/paginationStreamer/ReceiptPaginationStreamer'; import { Order } from '../../src/infrastructure/infrastructure'; +import { Duration } from 'js-joda'; describe('BlockHttp', () => { const helper = new IntegrationTestHelper(); @@ -43,6 +44,8 @@ describe('BlockHttp', () => { let networkType: NetworkType; let transactionHash; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -67,7 +70,7 @@ describe('BlockHttp', () => { describe('Setup Test Data', () => { it('Announce TransferTransaction FER', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/HashLockHttp.spec.ts b/e2e/infrastructure/HashLockHttp.spec.ts index 7f96ebeea5..40a1456a73 100644 --- a/e2e/infrastructure/HashLockHttp.spec.ts +++ b/e2e/infrastructure/HashLockHttp.spec.ts @@ -34,6 +34,7 @@ import { ChronoUnit } from 'js-joda'; import { SignedTransaction } from '../../src/model/transaction/SignedTransaction'; import { UnresolvedMosaicId } from '../../src/model/mosaic/UnresolvedMosaicId'; import { HashLockRepository } from '../../src/infrastructure/HashLockRepository'; +import { Duration } from 'js-joda'; describe('HashLockHttp', () => { const helper = new IntegrationTestHelper(); @@ -48,6 +49,8 @@ describe('HashLockHttp', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -68,7 +71,7 @@ describe('HashLockHttp', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -77,7 +80,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -92,7 +95,7 @@ describe('HashLockHttp', () => { mosaicId: UnresolvedMosaicId, ): any => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -112,7 +115,7 @@ describe('HashLockHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -122,7 +125,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -190,7 +193,7 @@ describe('HashLockHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, 0, [], @@ -199,7 +202,7 @@ describe('HashLockHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 0, 0, [], @@ -209,7 +212,7 @@ describe('HashLockHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, -1, [], @@ -219,7 +222,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/IntegrationTestHelper.ts b/e2e/infrastructure/IntegrationTestHelper.ts index 7797551300..3bfd3dc31f 100644 --- a/e2e/infrastructure/IntegrationTestHelper.ts +++ b/e2e/infrastructure/IntegrationTestHelper.ts @@ -29,6 +29,7 @@ import { SignedTransaction } from '../../src/model/transaction/SignedTransaction import { Transaction } from '../../src/model/transaction/Transaction'; import { UInt64 } from '../../src/model/UInt64'; import { TransactionService } from '../../src/service/TransactionService'; +import { Duration } from 'js-joda'; export class IntegrationTestHelper { public apiUrl: string; @@ -52,6 +53,7 @@ export class IntegrationTestHelper { public service = new BootstrapService(); public config: StartParams; public startEachTime = true; + public epochAdjustment: Duration; private async startBootstrapServer(): Promise<{ accounts: string[]; apiUrl: string }> { this.config = { @@ -112,6 +114,7 @@ export class IntegrationTestHelper { this.networkType = await this.repositoryFactory.getNetworkType().toPromise(); this.generationHash = await this.repositoryFactory.getGenerationHash().toPromise(); + this.epochAdjustment = await this.repositoryFactory.getEpochAdjustment().toPromise(); let index = 0; this.account = Account.createFromPrivateKey(accounts[index++], this.networkType); diff --git a/e2e/infrastructure/Listener.spec.ts b/e2e/infrastructure/Listener.spec.ts index 535a14fe8f..8dcea3873c 100644 --- a/e2e/infrastructure/Listener.spec.ts +++ b/e2e/infrastructure/Listener.spec.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { assert, expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { filter, mergeMap } from 'rxjs/operators'; import { TransactionRepository } from '../../src/infrastructure/TransactionRepository'; import { Account } from '../../src/model/account/Account'; @@ -47,6 +47,8 @@ describe('Listener', () => { let networkType: NetworkType; let transactionRepository: TransactionRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -71,7 +73,7 @@ describe('Listener', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -80,7 +82,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -95,7 +97,7 @@ describe('Listener', () => { mosaicId: UnresolvedMosaicId, ): void => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -109,7 +111,7 @@ describe('Listener', () => { describe('Confirmed', () => { it('confirmedTransactionsGiven address signer', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -125,7 +127,7 @@ describe('Listener', () => { it('confirmedTransactionsGiven address recipient', () => { const recipientAddress = account2.address; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), recipientAddress, [], PlainMessage.create('test-message'), @@ -140,7 +142,7 @@ describe('Listener', () => { describe('UnConfirmed', () => { it('unconfirmedTransactionsAdded', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -159,7 +161,7 @@ describe('Listener', () => { it('unconfirmedTransactionsRemoved', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -180,7 +182,7 @@ describe('Listener', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), cosignAccount1.address, [helper.createNetworkCurrency(10, true)], PlainMessage.create('test-message'), @@ -196,7 +198,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Create multisig account', () => { it('MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -206,7 +208,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -317,7 +319,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Restore multisig Accounts', () => { it('Restore Multisig Account', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, 0, [], @@ -325,7 +327,7 @@ describe('Listener', () => { networkType, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 0, 0, [], @@ -334,7 +336,7 @@ describe('Listener', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, -1, [], @@ -343,7 +345,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), @@ -366,7 +368,7 @@ describe('Listener', () => { it('transactionStatusGiven', () => { const mosaics = [helper.createNetworkCurrency(1000000000000)]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, mosaics, PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/MetadataHttp.spec.ts b/e2e/infrastructure/MetadataHttp.spec.ts index 9e4f0d62ab..0bcc1d4984 100644 --- a/e2e/infrastructure/MetadataHttp.spec.ts +++ b/e2e/infrastructure/MetadataHttp.spec.ts @@ -36,6 +36,7 @@ import { MetadataType } from '../../src/model/model'; import { Order, MetadataPaginationStreamer } from '../../src/infrastructure/infrastructure'; import { deepEqual } from 'assert'; import { take, toArray } from 'rxjs/operators'; +import { Duration } from 'js-joda'; describe('MetadataHttp', () => { const helper = new IntegrationTestHelper(); @@ -47,6 +48,8 @@ describe('MetadataHttp', () => { let networkType: NetworkType; let metadataRepository: MetadataRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -72,7 +75,7 @@ describe('MetadataHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -90,7 +93,7 @@ describe('MetadataHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -105,7 +108,7 @@ describe('MetadataHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), 23, @@ -115,7 +118,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -129,7 +132,7 @@ describe('MetadataHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), mosaicId, @@ -140,7 +143,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -154,7 +157,7 @@ describe('MetadataHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), namespaceId, @@ -165,7 +168,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index ad8b4f4384..7cae77425d 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -33,6 +33,7 @@ import { MosaicPaginationStreamer } from '../../src/infrastructure/paginationStr import { toArray, take } from 'rxjs/operators'; import { deepEqual } from 'assert'; import { TransactionGroup } from '../../src/infrastructure/TransactionGroup'; +import { Duration } from 'js-joda'; describe('MosaicHttp', () => { let mosaicId: MosaicId; @@ -44,6 +45,8 @@ describe('MosaicHttp', () => { const helper = new IntegrationTestHelper(); let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -70,7 +73,7 @@ describe('MosaicHttp', () => { expect(nonce.toHex()).to.be.equals('22EA84A6'); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -100,7 +103,7 @@ describe('MosaicHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(1000), networkType, @@ -115,7 +118,7 @@ describe('MosaicHttp', () => { describe('Setup test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -189,7 +192,7 @@ describe('MosaicHttp', () => { describe('Remove test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceId, mosaicId, diff --git a/e2e/infrastructure/MultisigAccounts.spec.ts b/e2e/infrastructure/MultisigAccounts.spec.ts index 4c4857e2a3..a04227f644 100644 --- a/e2e/infrastructure/MultisigAccounts.spec.ts +++ b/e2e/infrastructure/MultisigAccounts.spec.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Duration } from 'js-joda'; import { Account } from '../../src/model/account/Account'; import { NetworkType } from '../../src/model/network/NetworkType'; import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction'; @@ -29,6 +30,8 @@ describe('MultisigAccounts', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { multisigAccount = helper.multisigAccount; @@ -47,7 +50,7 @@ describe('MultisigAccounts', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -57,7 +60,7 @@ describe('MultisigAccounts', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/NamespaceHttp.spec.ts b/e2e/infrastructure/NamespaceHttp.spec.ts index 6a77577b32..d922bb5fa5 100644 --- a/e2e/infrastructure/NamespaceHttp.spec.ts +++ b/e2e/infrastructure/NamespaceHttp.spec.ts @@ -28,6 +28,7 @@ import { IntegrationTestHelper } from './IntegrationTestHelper'; import { NamespacePaginationStreamer } from '../../src/infrastructure/paginationStreamer/NamespacePaginationStreamer'; import { take, toArray } from 'rxjs/operators'; import { Order } from '../../src/infrastructure/infrastructure'; +import { Duration } from 'js-joda'; describe('NamespaceHttp', () => { let defaultNamespaceId: NamespaceId; @@ -37,6 +38,8 @@ describe('NamespaceHttp', () => { let generationHash: string; const helper = new IntegrationTestHelper(); + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -54,7 +57,7 @@ describe('NamespaceHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(1000), helper.networkType, @@ -68,7 +71,7 @@ describe('NamespaceHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, account.address, diff --git a/e2e/infrastructure/PersistentHarvesting.spec.ts b/e2e/infrastructure/PersistentHarvesting.spec.ts index 3d7d8013ac..637cc25333 100644 --- a/e2e/infrastructure/PersistentHarvesting.spec.ts +++ b/e2e/infrastructure/PersistentHarvesting.spec.ts @@ -23,6 +23,7 @@ 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(); @@ -30,6 +31,9 @@ describe('PersistentHarvesting', () => { let generationHash: string; let networkType: NetworkType; let remoteAccount: Account; + + const epochAdjustment = Duration.ofSeconds(1573430400); + const vrfKeyPair = Account.createFromPrivateKey( '82798EA9A2D2D202AFCCC82C40A287780BCA3C7F7A2FD5B754832804C6BE1BAA', NetworkType.MIJIN_TEST, @@ -58,7 +62,7 @@ describe('PersistentHarvesting', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -73,7 +77,7 @@ describe('PersistentHarvesting', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), vrfKeyPair.publicKey, LinkAction.Link, networkType, @@ -88,7 +92,7 @@ describe('PersistentHarvesting', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', LinkAction.Link, networkType, @@ -108,7 +112,7 @@ describe('PersistentHarvesting', () => { describe('transactions', () => { it('should create delegated harvesting transaction', () => { const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), remoteAccount.privateKey, vrfKeyPair.privateKey, 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', diff --git a/e2e/infrastructure/RestrictionHttp.spec.ts b/e2e/infrastructure/RestrictionHttp.spec.ts index 47d746bed5..f0ce229df6 100644 --- a/e2e/infrastructure/RestrictionHttp.spec.ts +++ b/e2e/infrastructure/RestrictionHttp.spec.ts @@ -36,6 +36,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { IntegrationTestHelper } from './IntegrationTestHelper'; import { AddressRestrictionFlag } from '../../src/model/restriction/AddressRestrictionFlag'; import { MosaicAddressRestriction } from '../../src/model/restriction/MosaicAddressRestriction'; +import { Duration } from 'js-joda'; describe('RestrictionHttp', () => { const helper = new IntegrationTestHelper(); @@ -48,6 +49,7 @@ describe('RestrictionHttp', () => { let mosaicId: MosaicId; let referenceMosaicId: MosaicId; let restrictionAccountRepository: RestrictionAccountRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -75,7 +77,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -94,7 +96,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); referenceMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, referenceMosaicId, MosaicFlags.create(true, true, true), @@ -111,7 +113,7 @@ describe('RestrictionHttp', () => { describe('Setup Test AccountAddressRestriction', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [account3.address], [], @@ -126,7 +128,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - Reference', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), referenceMosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -146,7 +148,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -167,7 +169,7 @@ describe('RestrictionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(60641), account3.address, @@ -177,7 +179,7 @@ describe('RestrictionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +223,7 @@ describe('RestrictionHttp', () => { describe('Remove test AccountRestriction - Address', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [], [account3.address], diff --git a/e2e/infrastructure/SecretLockHttp.spec.ts b/e2e/infrastructure/SecretLockHttp.spec.ts index f089e1e91f..dd9c213577 100644 --- a/e2e/infrastructure/SecretLockHttp.spec.ts +++ b/e2e/infrastructure/SecretLockHttp.spec.ts @@ -28,6 +28,7 @@ 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(); @@ -37,6 +38,7 @@ describe('SecretLockHttp', () => { let generationHash: string; let networkType: NetworkType; let secret: string; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -62,7 +64,7 @@ describe('SecretLockHttp', () => { describe('Create a hash lock', () => { it('Announce SecretLockTransaction', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 10c018af00..584fb819c7 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -137,7 +137,7 @@ describe('TransactionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -165,7 +165,7 @@ describe('TransactionHttp', () => { it('aggregate', () => { const nonce = MosaicNonce.createRandom(); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), nonce, MosaicId.createFromNonce(nonce, account.address), MosaicFlags.create(true, true, true), @@ -175,7 +175,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -189,7 +189,7 @@ describe('TransactionHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), 10, @@ -199,7 +199,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +221,7 @@ describe('TransactionHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), mosaicId, @@ -232,7 +232,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -255,7 +255,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -275,7 +275,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -294,14 +294,14 @@ describe('TransactionHttp', () => { describe('NamespaceRegistrationTransaction', () => { it('aggregate', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.epochAdjustment), 'root-test-namespace-' + Math.floor(Math.random() * 10000), UInt64.fromUint(5), networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [registerNamespaceTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -315,7 +315,7 @@ describe('TransactionHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), addressAlias, @@ -326,7 +326,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -348,7 +348,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -366,7 +366,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('aggregate', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -378,7 +378,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicGlobalRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -392,7 +392,7 @@ describe('TransactionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), account3.address, @@ -402,7 +402,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -416,7 +416,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -430,7 +430,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('aggregate', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -438,7 +438,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -451,7 +451,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [account3.address], [], @@ -469,7 +469,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [], [account3.address], @@ -477,7 +477,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -491,7 +491,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockIncomingAddress, [account3.address], [], @@ -505,7 +505,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockIncomingAddress, [], [account3.address], @@ -513,7 +513,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -527,7 +527,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForMosaic(AccountRestrictionModificationAction.Add, mosaicId); const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), MosaicRestrictionFlag.BlockMosaic, [mosaicId], [], @@ -546,7 +546,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Mosaic', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), MosaicRestrictionFlag.BlockMosaic, [], [mosaicId], @@ -554,7 +554,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -569,7 +569,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForOperation(AccountRestrictionModificationAction.Add, TransactionType.ACCOUNT_KEY_LINK); const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [TransactionType.ACCOUNT_KEY_LINK], [], @@ -588,7 +588,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Operation', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [], [TransactionType.ACCOUNT_KEY_LINK], @@ -596,7 +596,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account3.publicAccount)], networkType, [], @@ -610,7 +610,7 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -628,14 +628,14 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('aggregate', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), remoteAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [accountLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -649,7 +649,7 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -667,14 +667,14 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('aggregate', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [vrfKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -688,7 +688,7 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -706,14 +706,14 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('aggregate', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [nodeKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -727,7 +727,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('standalone', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), votingKey, 100, 300, @@ -749,7 +749,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('aggregate', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), votingKey, 100, 300, @@ -758,7 +758,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [votingLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -772,7 +772,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AliasAction.Link, addressAlias, account.address, @@ -792,7 +792,7 @@ describe('TransactionHttp', () => { describe('Transfer Transaction using address alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), addressAlias, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -808,7 +808,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('aggregate', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AliasAction.Unlink, addressAlias, account.address, @@ -816,7 +816,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [addressAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -830,7 +830,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -848,7 +848,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('aggregate', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -856,7 +856,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -870,7 +870,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AliasAction.Link, mosaicAlias, mosaicId, @@ -889,10 +889,16 @@ describe('TransactionHttp', () => { describe('HashLockTransaction - MosaicAlias', () => { it('standalone', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.epochAdjustment), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -907,7 +913,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('aggregate', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -915,7 +921,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [mosaicAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -928,10 +934,16 @@ describe('TransactionHttp', () => { describe('LockFundsTransaction', () => { it('standalone', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.epochAdjustment), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -944,10 +956,16 @@ describe('TransactionHttp', () => { }); describe('LockFundsTransaction', () => { it('aggregate', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.epochAdjustment), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10), signedTransaction, @@ -955,7 +973,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateLockFundsTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [lockFundsTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -968,7 +986,7 @@ describe('TransactionHttp', () => { describe('Aggregate Complete Transaction', () => { it('should announce aggregated complete transaction', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [], PlainMessage.create('Hi'), @@ -976,7 +994,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [tx.toAggregate(account.publicAccount)], networkType, [], @@ -990,7 +1008,7 @@ describe('TransactionHttp', () => { describe('SecretLockTransaction', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1012,7 +1030,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Sha3_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1022,7 +1040,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1037,7 +1055,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1054,7 +1072,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1064,7 +1082,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1076,7 +1094,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1091,7 +1109,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1101,7 +1119,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1118,7 +1136,7 @@ describe('TransactionHttp', () => { const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(helper.epochAdjustment, 1, ChronoUnit.HOURS), helper.createNetworkCurrency(10, false), UInt64.fromUint(11), LockHashAlgorithm.Op_Sha3_256, @@ -1132,7 +1150,7 @@ describe('TransactionHttp', () => { return helper.announce(signedSecretLockTx).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1156,7 +1174,7 @@ describe('TransactionHttp', () => { const secret = sha3_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1168,7 +1186,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1177,7 +1195,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1194,7 +1212,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_160(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1206,7 +1224,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1227,7 +1245,7 @@ describe('TransactionHttp', () => { const secret = new ripemd160().update(Buffer.from(hash, 'hex')).digest('hex'); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1237,7 +1255,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1246,7 +1264,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1266,7 +1284,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_256(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(1, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1277,7 +1295,7 @@ describe('TransactionHttp', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1299,7 +1317,7 @@ describe('TransactionHttp', () => { const secret = sha256(Buffer.from(hash, 'hex')); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1309,7 +1327,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1318,7 +1336,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1342,7 +1360,7 @@ describe('TransactionHttp', () => { const backAmount = helper.createNetworkCurrency(1); const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [sendAmount], PlainMessage.create('payout'), @@ -1350,7 +1368,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account.address, [backAmount], PlainMessage.create('payout'), @@ -1360,7 +1378,7 @@ describe('TransactionHttp', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.epochAdjustment), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1434,7 +1452,7 @@ describe('TransactionHttp', () => { describe('announce', () => { it('should return success when announce', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -1450,7 +1468,7 @@ describe('TransactionHttp', () => { describe('announceAggregateBonded', () => { it('should return success when announceAggregateBonded', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1)], PlainMessage.create('test-message'), @@ -1458,7 +1476,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(helper.epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/UnresolvedMapping.spec.ts b/e2e/infrastructure/UnresolvedMapping.spec.ts index 1eab3739af..1348a82cae 100644 --- a/e2e/infrastructure/UnresolvedMapping.spec.ts +++ b/e2e/infrastructure/UnresolvedMapping.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../src/core/format'; import { Account } from '../../src/model/account/Account'; import { PlainMessage } from '../../src/model/message/PlainMessage'; @@ -48,6 +49,7 @@ describe('Unresolved Mapping', () => { let mosaicId: MosaicId; let namespaceIdAddress: NamespaceId; let namespaceIdMosaic: NamespaceId; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -73,7 +75,7 @@ describe('Unresolved Mapping', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -92,7 +94,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -109,7 +111,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -125,7 +127,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdAddress, account.address, @@ -141,7 +143,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -163,7 +165,7 @@ describe('Unresolved Mapping', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(5), namespaceIdMosaic, @@ -174,7 +176,7 @@ describe('Unresolved Mapping', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -193,7 +195,7 @@ describe('Unresolved Mapping', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceIdMosaic, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -215,7 +217,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceIdMosaic, UInt64.fromUint(60641), namespaceIdAddress, @@ -225,7 +227,7 @@ describe('Unresolved Mapping', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -245,7 +247,7 @@ describe('Unresolved Mapping', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -269,7 +271,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceIdAddress, account.address, @@ -289,7 +291,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceIdMosaic, mosaicId, diff --git a/e2e/service/AccountService.spec.ts b/e2e/service/AccountService.spec.ts index dd7c2c7fa2..c5db172306 100644 --- a/e2e/service/AccountService.spec.ts +++ b/e2e/service/AccountService.spec.ts @@ -23,6 +23,7 @@ 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(); @@ -32,6 +33,7 @@ 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(() => { @@ -54,7 +56,7 @@ describe('AccountService', () => { describe('Create a namespace', () => { it('Announce NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), name, UInt64.fromUint(300000), networkType, diff --git a/e2e/service/BlockService.spec.ts b/e2e/service/BlockService.spec.ts index 883d02bd5e..f826c4760c 100644 --- a/e2e/service/BlockService.spec.ts +++ b/e2e/service/BlockService.spec.ts @@ -28,6 +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'; describe('BlockService', () => { const helper = new IntegrationTestHelper(); @@ -39,6 +40,7 @@ describe('BlockService', () => { let blockService: BlockService; let transactionRepository: TransactionRepository; let receiptRepository: ReceiptRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -64,7 +66,7 @@ describe('BlockService', () => { describe('Create a transfer', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/e2e/service/MetadataTransactionService.spec.ts b/e2e/service/MetadataTransactionService.spec.ts index 5ac0e0a4e7..9391a395b0 100644 --- a/e2e/service/MetadataTransactionService.spec.ts +++ b/e2e/service/MetadataTransactionService.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../src/core/format'; import { MetadataRepository } from '../../src/infrastructure/MetadataRepository'; import { Account } from '../../src/model/account/Account'; @@ -19,7 +20,8 @@ import { MetadataTransactionService } from '../../src/service/MetadataTransactio import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MetadataTransactionService', () => { - const deadline = Deadline.create(); + const epochAdjustment = Duration.ofSeconds(1573430400); + const deadline = Deadline.create(epochAdjustment); const key = UInt64.fromUint(Math.round(Math.random() * 10)); const newValue = 'new test value'; @@ -56,7 +58,7 @@ describe('MetadataTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, targetAccount.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -74,7 +76,7 @@ describe('MetadataTransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -90,7 +92,7 @@ describe('MetadataTransactionService', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), targetAccount.address, key, mosaicId, @@ -101,7 +103,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -116,7 +118,7 @@ describe('MetadataTransactionService', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), targetAccount.address, key, namespaceId, @@ -126,7 +128,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [namespaceMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -234,7 +236,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -262,7 +264,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -290,7 +292,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], diff --git a/e2e/service/MosaicRestrictionTransactionService.spec.ts b/e2e/service/MosaicRestrictionTransactionService.spec.ts index 6f48fba7da..a4d6b733d7 100644 --- a/e2e/service/MosaicRestrictionTransactionService.spec.ts +++ b/e2e/service/MosaicRestrictionTransactionService.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { KeyGenerator } from '../../src/core/format/KeyGenerator'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; import { RestrictionMosaicRepository } from '../../src/infrastructure/RestrictionMosaicRepository'; @@ -24,7 +25,8 @@ import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRes import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MosaicRestrictionTransactionService', () => { - const deadline = Deadline.create(); + const epochAdjustment = Duration.ofSeconds(1573430400); + const deadline = Deadline.create(epochAdjustment); const key = KeyGenerator.generateUInt64Key('TestKey'); let account: Account; let restrictionRepository: RestrictionMosaicRepository; @@ -61,7 +63,7 @@ describe('MosaicRestrictionTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -78,7 +80,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, key, UInt64.fromUint(0), @@ -97,7 +99,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, key, account.address, @@ -107,7 +109,7 @@ describe('MosaicRestrictionTransactionService', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -122,7 +124,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -139,7 +141,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -155,7 +157,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdAddress, account.address, @@ -171,7 +173,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -291,7 +293,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicGlobalRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], networkType, [], @@ -311,7 +313,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicAddressRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/service/TransactionService.spec.ts b/e2e/service/TransactionService.spec.ts index 1a37328447..cd57d7f80a 100644 --- a/e2e/service/TransactionService.spec.ts +++ b/e2e/service/TransactionService.spec.ts @@ -15,6 +15,7 @@ */ 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'; @@ -59,6 +60,7 @@ describe('TransactionService', () => { let networkType: NetworkType; let transactionService: TransactionService; let transactionRepository: TransactionRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -84,7 +86,7 @@ describe('TransactionService', () => { function buildAggregateTransaction(): AggregateTransaction { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -93,7 +95,7 @@ describe('TransactionService', () => { ); // Unlink MosaicAlias const mosaicAliasTransactionUnlink = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -105,7 +107,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); newMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, newMosaicId, MosaicFlags.create(true, true, false), @@ -116,7 +118,7 @@ describe('TransactionService', () => { ); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), newMosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -126,7 +128,7 @@ describe('TransactionService', () => { // Link namespace with new MosaicId const mosaicAliasTransactionRelink = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, mosaicAlias, newMosaicId, @@ -136,7 +138,7 @@ describe('TransactionService', () => { // Use new mosaicAlias in metadata const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(5), mosaicAlias, @@ -146,7 +148,7 @@ describe('TransactionService', () => { helper.maxFee, ); return AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), mosaicAliasTransactionUnlink.toAggregate(account.publicAccount), @@ -170,7 +172,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(20), networkType, @@ -187,7 +189,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -203,7 +205,7 @@ describe('TransactionService', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, addressAlias, account.address, @@ -222,7 +224,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -241,7 +243,7 @@ describe('TransactionService', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -257,7 +259,7 @@ describe('TransactionService', () => { describe('Setup MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, mosaicAlias, mosaicId, @@ -273,7 +275,7 @@ describe('TransactionService', () => { describe('Create Transfer with alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -311,7 +313,7 @@ describe('TransactionService', () => { describe('Transfer mosaic to account 3', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account3.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -329,7 +331,7 @@ describe('TransactionService', () => { const transactions: SignedTransaction[] = []; // 1. Transfer A -> B const transaction1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -340,7 +342,7 @@ describe('TransactionService', () => { // 2. Transfer C -> D const transaction2 = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), cosignAccount4.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), diff --git a/e2e/service/TransactionService_AggregateBonded.spec.ts b/e2e/service/TransactionService_AggregateBonded.spec.ts index 92f0ecf19b..6c777ae3b9 100644 --- a/e2e/service/TransactionService_AggregateBonded.spec.ts +++ b/e2e/service/TransactionService_AggregateBonded.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; import { Account } from '../../src/model/account/Account'; import { Address } from '../../src/model/account/Address'; @@ -49,6 +49,7 @@ describe('TransactionService - AggregateBonded', () => { let networkType: NetworkType; let transactionService: TransactionService; let NetworkCurrencyLocalId: MosaicId; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -74,7 +75,7 @@ describe('TransactionService - AggregateBonded', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -83,7 +84,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -111,7 +112,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -121,7 +122,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -146,7 +147,7 @@ describe('TransactionService - AggregateBonded', () => { describe('should announce transaction', () => { it('announce', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -169,7 +170,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -189,7 +190,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -216,7 +217,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', async () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, 0, [], @@ -225,7 +226,7 @@ describe('TransactionService - AggregateBonded', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 0, 0, [], @@ -235,7 +236,7 @@ describe('TransactionService - AggregateBonded', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), -1, -1, [], @@ -245,7 +246,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/src/core/format/Utilities.ts b/src/core/format/Utilities.ts index 9dc0dbb02a..727824e1af 100644 --- a/src/core/format/Utilities.ts +++ b/src/core/format/Utilities.ts @@ -101,11 +101,11 @@ export const throwInvalidFqn = (reason: any, name: any): void => { export const extractPartName = (name: string, start: number, size: number): string => { if (0 === size) { - this.throwInvalidFqn('empty part', name); + throwInvalidFqn('empty part', name); } const partName = name.substr(start, size); if (!idGeneratorConst.name_pattern.test(partName)) { - this.throwInvalidFqn(`invalid part name [${partName}]`, name); + throwInvalidFqn(`invalid part name [${partName}]`, name); } return partName; }; diff --git a/src/core/utils/DtoMapping.ts b/src/core/utils/DtoMapping.ts index 9bf8aae4b2..ea3247617a 100644 --- a/src/core/utils/DtoMapping.ts +++ b/src/core/utils/DtoMapping.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { Duration } from 'js-joda'; import { Address } from '../../model/account/Address'; import { MosaicId } from '../../model/mosaic/MosaicId'; import { AccountRestriction } from '../../model/restriction/AccountRestriction'; @@ -78,4 +79,45 @@ export class DtoMapping { public static mapEnum(value: E1 | undefined): E2 { return (value as unknown) as E2; } + + /** + * It parse a server time/duration configuration like: - 1000ms 1000 milliseconds - 15s 15 seconds + * - 5m 5 minutes - 2h 2 hours - 10d 10 days + * + *

into a @{@link Duration} object + * + * @param serverValue time. + * @return {Duration} an instant from that value. + */ + public static parseServerDuration(serverValue: string): Duration { + const preprocessedValue = serverValue.replace(`'`, '').trim(); + const regex = `([0-9]+)([hdms]+)[:\\s]?$`; + let duration = Duration.ofSeconds(0); + const matcher = preprocessedValue.match(regex); + if (matcher && matcher.length === 3) { + const num = parseInt(matcher[1]); + const type = matcher[2]; + switch (type) { + case 'ms': + duration = duration.plusMillis(num); + break; + case 's': + duration = duration.plusSeconds(num); + break; + case 'm': + duration = duration.plusMinutes(num); + break; + case 'h': + duration = duration.plusHours(num); + break; + case 'd': + duration = duration.plusDays(num); + break; + default: + throw new Error('Duration value format is not recognized.'); + } + return duration; + } + throw new Error(`Duration value format is not recognized.`); + } } diff --git a/src/infrastructure/RepositoryFactory.ts b/src/infrastructure/RepositoryFactory.ts index db81620220..d106522066 100644 --- a/src/infrastructure/RepositoryFactory.ts +++ b/src/infrastructure/RepositoryFactory.ts @@ -33,6 +33,7 @@ import { TransactionRepository } from './TransactionRepository'; import { TransactionStatusRepository } from './TransactionStatusRepository'; import { HashLockRepository } from './HashLockRepository'; import { SecretLockRepository } from './SecretLockRepository'; +import { Duration } from 'js-joda'; /** * A repository factory allows clients to create repositories to access NEM Server without knowing @@ -136,4 +137,9 @@ export interface RepositoryFactory { * @returns a newly created {@link IListener} */ createListener(): IListener; + + /** + * @returns nemesis block epoch + */ + getEpochAdjustment(): Observable; } diff --git a/src/infrastructure/RepositoryFactoryConfig.ts b/src/infrastructure/RepositoryFactoryConfig.ts index d8d5f01d8c..d533be7cc4 100644 --- a/src/infrastructure/RepositoryFactoryConfig.ts +++ b/src/infrastructure/RepositoryFactoryConfig.ts @@ -40,4 +40,9 @@ export interface RepositoryFactoryConfig { * 2) or node-fetch if running on server (window.fetch not found) */ fetchApi?: any; + + /** + * The nemesis block creation epoch + */ + epochAdjustment?: number; } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index 2982ae80ec..979b928455 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -53,6 +53,8 @@ import { HashLockRepository } from './HashLockRepository'; import { SecretLockRepository } from './SecretLockRepository'; import { SecretLockHttp } from './SecretLockHttp'; import { HashLockHttp } from './HashLockHttp'; +import { Duration } from 'js-joda'; +import { DtoMapping } from '../core/utils/DtoMapping'; /** * Receipt http repository. * @@ -64,6 +66,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { private readonly websocketUrl: string; private readonly websocketInjected?: any; private readonly fetchApi?: any; + private readonly epochAdjustment: Observable; /** * Constructor @@ -71,11 +74,20 @@ export class RepositoryFactoryHttp implements RepositoryFactory { * @param configs optional repository factory configs */ constructor(url: string, configs?: RepositoryFactoryConfig) { + const networkRepo = this.createNetworkRepository(); this.url = url; this.fetchApi = configs?.fetchApi; - this.networkType = configs?.networkType - ? observableOf(configs.networkType) - : this.createNetworkRepository().getNetworkType().pipe(shareReplay(1)); + this.networkType = configs?.networkType ? observableOf(configs.networkType) : networkRepo.getNetworkType().pipe(shareReplay(1)); + this.epochAdjustment = configs?.epochAdjustment + ? observableOf(Duration.ofSeconds(configs.epochAdjustment)) + : networkRepo + .getNetworkProperties() + .pipe( + map((property) => { + return DtoMapping.parseServerDuration(property.network.epochAdjustment ?? '-'); + }), + ) + .pipe(shareReplay(1)); this.generationHash = configs?.generationHash ? observableOf(configs?.generationHash) : this.createNodeRepository() @@ -161,4 +173,8 @@ export class RepositoryFactoryHttp implements RepositoryFactory { createListener(): IListener { return new Listener(this.websocketUrl, this.createNamespaceRepository(), this.websocketInjected); } + + getEpochAdjustment(): Observable { + return this.epochAdjustment; + } } diff --git a/src/infrastructure/TransactionStatusHttp.ts b/src/infrastructure/TransactionStatusHttp.ts index a416386b9c..094e786bc0 100644 --- a/src/infrastructure/TransactionStatusHttp.ts +++ b/src/infrastructure/TransactionStatusHttp.ts @@ -37,9 +37,10 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo /** * Constructor * @param url Base catapult-rest url + * @param epochAdjustment Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, fetchApi?: any) { + constructor(url: string, epochAdjustment?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionStatusRoutesApi = new TransactionStatusRoutesApi(this.config()); } diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts index b041233385..50751818ea 100644 --- a/src/model/transaction/AccountAddressRestrictionTransaction.ts +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -121,7 +121,7 @@ export class AccountAddressRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountAddressRestrictionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { diff --git a/src/model/transaction/AccountKeyLinkTransaction.ts b/src/model/transaction/AccountKeyLinkTransaction.ts index a0752da9a1..f6a7d5e6ae 100644 --- a/src/model/transaction/AccountKeyLinkTransaction.ts +++ b/src/model/transaction/AccountKeyLinkTransaction.ts @@ -118,7 +118,9 @@ export class AccountKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AccountKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/AccountMetadataTransaction.ts b/src/model/transaction/AccountMetadataTransaction.ts index e56744c402..58715055c6 100644 --- a/src/model/transaction/AccountMetadataTransaction.ts +++ b/src/model/transaction/AccountMetadataTransaction.ts @@ -140,7 +140,9 @@ export class AccountMetadataTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AccountMetadataTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), builder.getValueSizeDelta(), diff --git a/src/model/transaction/AccountMosaicRestrictionTransaction.ts b/src/model/transaction/AccountMosaicRestrictionTransaction.ts index fe92153b6d..63d8d38356 100644 --- a/src/model/transaction/AccountMosaicRestrictionTransaction.ts +++ b/src/model/transaction/AccountMosaicRestrictionTransaction.ts @@ -120,7 +120,7 @@ export class AccountMosaicRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountMosaicRestrictionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { diff --git a/src/model/transaction/AccountOperationRestrictionTransaction.ts b/src/model/transaction/AccountOperationRestrictionTransaction.ts index e6c0121766..41ceec7258 100644 --- a/src/model/transaction/AccountOperationRestrictionTransaction.ts +++ b/src/model/transaction/AccountOperationRestrictionTransaction.ts @@ -115,7 +115,7 @@ export class AccountOperationRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountOperationRestrictionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions(), diff --git a/src/model/transaction/AddressAliasTransaction.ts b/src/model/transaction/AddressAliasTransaction.ts index 28e43c4791..dbf0829e4c 100644 --- a/src/model/transaction/AddressAliasTransaction.ts +++ b/src/model/transaction/AddressAliasTransaction.ts @@ -130,7 +130,9 @@ export class AddressAliasTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AddressAliasTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), Address.createFromEncoded(Convert.uint8ToHex(builder.getAddress().address)), diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index 287929f191..05433f672c 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ChronoUnit, Instant, LocalDateTime, ZoneId } from 'js-joda'; +import { ChronoUnit, Duration, Instant, LocalDateTime, ZoneId } from 'js-joda'; import { UInt64 } from '../UInt64'; /** @@ -23,33 +23,25 @@ import { UInt64 } from '../UInt64'; */ export class Deadline { /** - * @type {number} + * Deadline value (without Nemesis epoch adjustment) */ - public static timestampNemesisBlock = 1573430400; + public adjustedValue: number; /** - * Deadline value - */ - public value: LocalDateTime; - - /** - * Create deadline model - * @param deadline - * @param chronoUnit + * Create deadline model. Default to 2 chrono hours in advance. + * @param {Duration} epochAdjustment the network's epoch adjustment (seconds). Defined in the network/properties. e.g. Duration.ofSeconds(1573430400); + * @param {number} deadline the deadline unit value. + * @param {ChronoUnit} chronoUnit the crhono unit. e.g ChronoUnit.HOURS * @returns {Deadline} */ - public static create(deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { - const networkTimeStamp = new Date().getTime(); - const timeStampDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); - const deadlineDateTime = timeStampDateTime.plus(deadline, chronoUnit); + public static create(epochAdjustment: Duration, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { + const now = Instant.now(); + const deadlineDateTime = now.plus(deadline, chronoUnit); if (deadline <= 0) { throw new Error('deadline should be greater than 0'); - } else if (timeStampDateTime.plus(24, ChronoUnit.HOURS).compareTo(deadlineDateTime) !== 1) { - throw new Error('deadline should be less than 24 hours'); } - - return new Deadline(deadlineDateTime); + return new Deadline(deadlineDateTime.minusMillis(epochAdjustment.toMillis()).toEpochMilli()); } /** @@ -59,7 +51,7 @@ export class Deadline { * @returns {Deadline} */ public static createEmtpy(): Deadline { - return new Deadline(LocalDateTime.MIN); + return new Deadline(0); } /** @@ -68,34 +60,47 @@ export class Deadline { */ public static createFromDTO(value: string | number[]): Deadline { const uint64Value = 'string' === typeof value ? UInt64.fromNumericString(value) : new UInt64(value); - const dateSeconds = uint64Value.compact(); - const deadline = LocalDateTime.ofInstant( - Instant.ofEpochMilli(Math.round(dateSeconds + Deadline.timestampNemesisBlock * 1000)), - ZoneId.SYSTEM, - ); - return new Deadline(deadline); + return new Deadline(uint64Value.compact()); } /** - * @param deadline + * Constructor + * @param adjustedValue Adjusted value. (Local datetime minus nemesis epoch adjustment) */ - private constructor(deadline: LocalDateTime) { - this.value = deadline; + private constructor(adjustedValue: number) { + this.adjustedValue = adjustedValue; } /** * @internal */ public toDTO(): number[] { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - Deadline.timestampNemesisBlock * 1000).toDTO(); + return UInt64.fromUint(this.adjustedValue).toDTO(); } /** * @internal */ public toString(): string { - return UInt64.fromUint( - this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - Deadline.timestampNemesisBlock * 1000, - ).toString(); + return UInt64.fromUint(this.adjustedValue).toString(); + } + + /** + * Returns deadline as local date time. + * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @returns {LocalDateTime} + */ + public toLocalDateTime(epochAdjustment: Duration): LocalDateTime { + return LocalDateTime.ofInstant(Instant.ofEpochMilli(this.adjustedValue).plusMillis(epochAdjustment.toMillis()), ZoneId.SYSTEM); + } + + /** + * Returns deadline as local date time. + * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @param zoneId the Zone Id. + * @returns {LocalDateTime} + */ + public toLocalDateTimeGivenTimeZone(epochAdjustment: Duration, zoneId: ZoneId): LocalDateTime { + return LocalDateTime.ofInstant(Instant.ofEpochMilli(this.adjustedValue).plusMillis(epochAdjustment.toMillis()), zoneId); } } diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index f4d36e967d..d8c56b795a 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -145,7 +145,7 @@ export class LockFundsTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = LockFundsTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp), new Mosaic(new MosaicId(builder.getMosaic().mosaicId.unresolvedMosaicId), new UInt64(builder.getMosaic().amount.amount)), new UInt64(builder.getDuration().blockDuration), new SignedTransaction('', Convert.uint8ToHex(builder.getHash().hash256), '', TransactionType.AGGREGATE_BONDED, networkType), diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index 3e5571b888..a3ac17d80d 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -157,7 +157,7 @@ export class MosaicAddressRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicAddressRestrictionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), diff --git a/src/model/transaction/MosaicAliasTransaction.ts b/src/model/transaction/MosaicAliasTransaction.ts index ac7b10c57e..434eafa0ea 100644 --- a/src/model/transaction/MosaicAliasTransaction.ts +++ b/src/model/transaction/MosaicAliasTransaction.ts @@ -127,7 +127,9 @@ export class MosaicAliasTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = MosaicAliasTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), new MosaicId(builder.getMosaicId().mosaicId), diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index efa5b32c9d..8b5507538a 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -149,7 +149,7 @@ export class MosaicDefinitionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicDefinitionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp), MosaicNonce.createFromUint8Array(builder.getNonce().serialize()), new MosaicId(builder.getId().mosaicId), diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts index b2049c001a..950be36259 100644 --- a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -173,7 +173,7 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicGlobalRestrictionTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), diff --git a/src/model/transaction/MosaicMetadataTransaction.ts b/src/model/transaction/MosaicMetadataTransaction.ts index f5370e986f..2ca0469791 100644 --- a/src/model/transaction/MosaicMetadataTransaction.ts +++ b/src/model/transaction/MosaicMetadataTransaction.ts @@ -152,7 +152,9 @@ export class MosaicMetadataTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = MosaicMetadataTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getTargetMosaicId().unresolvedMosaicId).toHex()), diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 05e1275d82..fcafc5a2b6 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -133,7 +133,7 @@ export class MosaicSupplyChangeTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicSupplyChangeTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), builder.getAction().valueOf(), diff --git a/src/model/transaction/MultisigAccountModificationTransaction.ts b/src/model/transaction/MultisigAccountModificationTransaction.ts index 9ae2434d23..690e3837a2 100644 --- a/src/model/transaction/MultisigAccountModificationTransaction.ts +++ b/src/model/transaction/MultisigAccountModificationTransaction.ts @@ -143,7 +143,7 @@ export class MultisigAccountModificationTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MultisigAccountModificationTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp), builder.getMinApprovalDelta(), builder.getMinRemovalDelta(), diff --git a/src/model/transaction/NamespaceMetadataTransaction.ts b/src/model/transaction/NamespaceMetadataTransaction.ts index 3447bb2af4..16aeebf9ba 100644 --- a/src/model/transaction/NamespaceMetadataTransaction.ts +++ b/src/model/transaction/NamespaceMetadataTransaction.ts @@ -150,7 +150,7 @@ export class NamespaceMetadataTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = NamespaceMetadataTransaction.create( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 5f30f9a8d8..6c890b9a71 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -189,7 +189,7 @@ export class NamespaceRegistrationTransaction extends Transaction { registrationType === NamespaceRegistrationType.RootNamespace ? NamespaceRegistrationTransaction.createRootNamespace( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new UInt64(builder.getDuration()!.blockDuration), @@ -200,7 +200,7 @@ export class NamespaceRegistrationTransaction extends Transaction { ) : NamespaceRegistrationTransaction.createSubNamespace( isEmbedded - ? Deadline.create() + ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new NamespaceId(builder.getParentId()!.namespaceId), diff --git a/src/model/transaction/NodeKeyLinkTransaction.ts b/src/model/transaction/NodeKeyLinkTransaction.ts index 65e66fbff3..31c44a8dac 100644 --- a/src/model/transaction/NodeKeyLinkTransaction.ts +++ b/src/model/transaction/NodeKeyLinkTransaction.ts @@ -114,7 +114,9 @@ export class NodeKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = NodeKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index 1d1b4d9a64..ff196f3871 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -153,7 +153,7 @@ export class SecretLockTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = SecretLockTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp), new Mosaic( UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaic().mosaicId.unresolvedMosaicId).toHex()), new UInt64(builder.getMosaic().amount.amount), diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 0584e6ef81..2c56586186 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -130,7 +130,9 @@ export class SecretProofTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = SecretProofTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp), builder.getHashAlgorithm().valueOf(), Convert.uint8ToHex(builder.getSecret().hash256), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), diff --git a/src/model/transaction/Transaction.ts b/src/model/transaction/Transaction.ts index d3c2742d80..f607931444 100644 --- a/src/model/transaction/Transaction.ts +++ b/src/model/transaction/Transaction.ts @@ -358,7 +358,7 @@ export abstract class Transaction { * @returns {Transaction} * @memberof Transaction */ - public reapplyGiven(deadline: Deadline = Deadline.create()): Transaction { + public reapplyGiven(deadline: Deadline): Transaction { if (this.isUnannounced()) { return DtoMapping.assign(this, { deadline }); } diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 8ac85d752a..4cf4274a91 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -145,7 +145,7 @@ export class TransferTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = TransferTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), builder.getMosaics().map((mosaic) => { const id = new UInt64(mosaic.mosaicId.unresolvedMosaicId).toHex(); diff --git a/src/model/transaction/VotingKeyLinkTransaction.ts b/src/model/transaction/VotingKeyLinkTransaction.ts index 7c7f737bd8..a85e876884 100644 --- a/src/model/transaction/VotingKeyLinkTransaction.ts +++ b/src/model/transaction/VotingKeyLinkTransaction.ts @@ -132,7 +132,9 @@ export class VotingKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = VotingKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().votingKey), builder.getStartEpoch().finalizationEpoch, builder.getEndEpoch().finalizationEpoch, diff --git a/src/model/transaction/VrfKeyLinkTransaction.ts b/src/model/transaction/VrfKeyLinkTransaction.ts index c32c004251..a6fd6317cb 100644 --- a/src/model/transaction/VrfKeyLinkTransaction.ts +++ b/src/model/transaction/VrfKeyLinkTransaction.ts @@ -114,7 +114,7 @@ export class VrfKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = VrfKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/test/core/utils/DtoMapping.spec.ts b/test/core/utils/DtoMapping.spec.ts index 0ab2994b2e..1000742b67 100644 --- a/test/core/utils/DtoMapping.spec.ts +++ b/test/core/utils/DtoMapping.spec.ts @@ -63,4 +63,32 @@ describe('DtoMapping', () => { expect(result).not.to.be.undefined; expect((result.accountRestrictions.restrictions[0].values[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); }); + + it('parseServerDuration', () => { + const epochS = '12345s'; + expect(DtoMapping.parseServerDuration(epochS).seconds()).to.be.equal(12345); + const epochM = '12345m'; + expect(DtoMapping.parseServerDuration(epochM).toMinutes()).to.be.equal(12345); + const epochH = '12345h'; + expect(DtoMapping.parseServerDuration(epochH).toHours()).to.be.equal(12345); + const epochMS = '12345ms'; + expect(DtoMapping.parseServerDuration(epochMS).toMillis()).to.be.equal(12345); + const epochD = '12345d'; + expect(DtoMapping.parseServerDuration(epochD).toDays()).to.be.equal(12345); + }); + + it('parseServerDuration - exception', () => { + expect(() => { + const epochS = '12345g'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + expect(() => { + const epochS = 'adfs'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + expect(() => { + const epochS = '123s45'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + }); }); diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 1a4152f669..8a61b47541 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -69,10 +69,12 @@ import { NodeKeyLinkTransaction } from '../../../src/model/transaction/NodeKeyLi import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; +import { Duration } from 'js-joda'; describe('TransactionMapping - createFromPayload', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +82,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -99,7 +101,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -117,7 +119,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -136,7 +138,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -157,7 +159,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -176,7 +178,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -199,7 +201,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -220,7 +222,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -241,7 +243,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -262,7 +264,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -284,7 +286,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -304,7 +306,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -324,7 +326,7 @@ describe('TransactionMapping - createFromPayload', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -347,7 +349,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -366,7 +368,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -390,7 +392,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -398,25 +400,25 @@ describe('TransactionMapping - createFromPayload', () => { ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -424,13 +426,13 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -440,7 +442,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -449,7 +451,7 @@ describe('TransactionMapping - createFromPayload', () => { UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -457,7 +459,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -466,7 +468,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -476,7 +478,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -484,7 +486,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -493,7 +495,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -524,7 +526,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -532,7 +534,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -547,10 +549,10 @@ describe('TransactionMapping - createFromPayload', () => { }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -568,7 +570,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -583,7 +585,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -598,7 +600,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -614,7 +616,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), key, 1, 3, @@ -633,7 +635,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -649,7 +651,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -665,7 +667,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -691,7 +693,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -714,7 +716,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -738,7 +740,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -758,7 +760,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -781,7 +783,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -804,7 +806,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -823,13 +825,14 @@ describe('TransactionMapping - createFromPayload', () => { describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should create TransferTransaction - Address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -844,7 +847,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - NamespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId([33347626, 3779697293]), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -860,7 +863,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - Encrypted Message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], new EncryptedMessage('12324556'), @@ -875,7 +878,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -889,7 +892,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -903,7 +906,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -918,7 +921,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VotingKeyLinkTransaction', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), key, 1, 3, @@ -936,7 +939,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -955,7 +958,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -972,7 +975,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -992,7 +995,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -1009,7 +1012,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -1023,7 +1026,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -1044,7 +1047,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -1061,7 +1064,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1080,7 +1083,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1100,7 +1103,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(new MosaicId([1, 1]), UInt64.fromUint(10)), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1119,7 +1122,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -1140,7 +1143,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), recipientAddress, @@ -1159,7 +1162,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -1178,7 +1181,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1186,7 +1189,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -1200,7 +1203,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1208,7 +1211,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -1221,10 +1224,10 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -1239,7 +1242,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -1252,7 +1255,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -1264,7 +1267,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -1290,7 +1293,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -1313,7 +1316,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -1332,7 +1335,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1353,7 +1356,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), diff --git a/test/core/utils/TransactionMappingWithSignatures.spec.ts b/test/core/utils/TransactionMappingWithSignatures.spec.ts index 936e5382fc..1bd8cd4ee7 100644 --- a/test/core/utils/TransactionMappingWithSignatures.spec.ts +++ b/test/core/utils/TransactionMappingWithSignatures.spec.ts @@ -66,6 +66,7 @@ import { NodeKeyLinkTransaction } from '../../../src/model/transaction/NodeKeyLi import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; +import { Duration } from 'js-joda'; describe('TransactionMapping - createFromPayload with optional sigature and signer', () => { let account: Account; @@ -73,6 +74,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const testSignature = '4CBA582B4C898FD6D218499251FE8EE1214D3715545023123F70D25389D577A96E74C1FCD07FF8F0D678A4DA5CAD8CCB173DDD9F7975A6985ADCD7AD625B170F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +82,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -110,7 +112,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -140,7 +142,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -172,7 +174,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -205,7 +207,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -236,7 +238,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -271,7 +273,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -305,7 +307,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -337,7 +339,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -369,7 +371,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -404,7 +406,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -435,7 +437,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -471,7 +473,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -479,25 +481,25 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -505,13 +507,13 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -521,7 +523,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -530,7 +532,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -538,7 +540,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -547,7 +549,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -557,7 +559,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -565,7 +567,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -574,7 +576,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -617,7 +619,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -625,7 +627,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -652,10 +654,10 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -685,7 +687,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -712,7 +714,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -739,7 +741,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -767,7 +769,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), key, 1, 3, @@ -798,7 +800,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -826,7 +828,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -854,7 +856,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -893,7 +895,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -928,7 +930,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -964,7 +966,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -996,7 +998,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1031,7 +1033,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -1066,7 +1068,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index 408a5a0289..2a6e78c47d 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -34,6 +34,7 @@ import { TransactionStatusError } from '../../src/model/transaction/TransactionS import { TransferTransaction } from '../../src/model/transaction/TransferTransaction'; import { UInt64 } from '../../src/model/UInt64'; import { FinalizedBlock } from '../../src/model/blockchain/FinalizedBlock'; +import { Duration } from 'js-joda'; describe('Listener', () => { const account = Account.createFromPrivateKey( @@ -43,20 +44,21 @@ describe('Listener', () => { let namespaceRepoMock: NamespaceRepository; let namespaceRepo: NamespaceRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); beforeEach(() => { namespaceRepoMock = mock(); namespaceRepo = instance(namespaceRepoMock); }); it('should createComplete a WebSocket instance given url parameter', () => { - const listener = new Listener('http://localhost:3000/ws', namespaceRepo); + const listener = new Listener('http://localhost:3000/ws', namespaceRepo, epochAdjustment); expect('http://localhost:3000/ws').to.be.equal(listener.url); listener.close(); }); describe('isOpen', () => { it('should return false when listener is created and not opened', () => { - const listener = new Listener('http://localhost:3000', namespaceRepo); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment); expect(listener.isOpen()).to.be.false; listener.close(); }); @@ -192,7 +194,7 @@ describe('Listener', () => { describe('onerror', () => { it('should reject because of wrong server url', async () => { - const listener = new Listener('https://notcorrecturl:0000', namespaceRepo); + const listener = new Listener('https://notcorrecturl:0000', namespaceRepo, epochAdjustment); await listener .open() .then(() => { @@ -235,7 +237,7 @@ describe('Listener', () => { ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -279,7 +281,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -324,7 +326,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -368,7 +370,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias2, [], PlainMessage.create('test-message'), @@ -414,7 +416,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias2, [], PlainMessage.create('test-message'), diff --git a/test/infrastructure/MetadataHttp.spec.ts b/test/infrastructure/MetadataHttp.spec.ts index 62ef2d0e55..1443a795d5 100644 --- a/test/infrastructure/MetadataHttp.spec.ts +++ b/test/infrastructure/MetadataHttp.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { MetadataEntryDTO, MetadataRoutesApi, @@ -42,6 +43,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MetadataTransactionService } from '../../src/service/MetadataTransactionService'; describe('MetadataHttp', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const mosaicId = new MosaicId('941299B2B7E1291C'); const namespaceId = new NamespaceId('some.address'); @@ -361,7 +363,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -394,7 +396,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, mosaicId, @@ -428,7 +430,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, namespaceId, @@ -461,7 +463,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -490,7 +492,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, mosaicId, @@ -520,7 +522,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, namespaceId, diff --git a/test/infrastructure/Page.spec.ts b/test/infrastructure/Page.spec.ts index 56f08b6d9d..dc08df2b5c 100644 --- a/test/infrastructure/Page.spec.ts +++ b/test/infrastructure/Page.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Page } from '../../src/infrastructure/infrastructure'; import { PlainMessage } from '../../src/model/message/PlainMessage'; import { NetworkType } from '../../src/model/network/NetworkType'; @@ -24,10 +25,19 @@ import { TransferTransaction } from '../../src/model/transaction/TransferTransac import { TestingAccount } from '../conf/conf.spec'; describe('Page', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); it('should create Page', () => { const account = TestingAccount; let page = new Page( - [TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [ + TransferTransaction.create( + Deadline.create(epochAdjustment), + account.address, + [], + PlainMessage.create(''), + NetworkType.TEST_NET, + ), + ], 1, 1, ); @@ -37,7 +47,15 @@ describe('Page', () => { expect(page.isLastPage).to.be.false; page = new Page( - [TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [ + TransferTransaction.create( + Deadline.create(epochAdjustment), + account.address, + [], + PlainMessage.create(''), + NetworkType.TEST_NET, + ), + ], 2, 2, ); diff --git a/test/infrastructure/RepositoryFactory.spec.ts b/test/infrastructure/RepositoryFactory.spec.ts index 02e2a74ddb..65e1274e77 100644 --- a/test/infrastructure/RepositoryFactory.spec.ts +++ b/test/infrastructure/RepositoryFactory.spec.ts @@ -41,6 +41,7 @@ import { NetworkType } from '../../src/model/network/NetworkType'; import { NodeInfo } from '../../src/model/node/NodeInfo'; import { HashLockHttp } from '../../src/infrastructure/HashLockHttp'; import { SecretLockHttp } from '../../src/infrastructure/SecretLockHttp'; +import { NetworkConfigurationDTO } from 'symbol-openapi-typescript-fetch-client'; describe('RepositoryFactory', () => { it('Should create repositories', () => { @@ -121,6 +122,7 @@ describe('RepositoryFactory', () => { } })('http://localhost:3000', { generationHash: 'testHash', + epochAdjustment: 1573430400, }); expect(counter).to.be.equals(0); @@ -135,6 +137,51 @@ describe('RepositoryFactory', () => { }); }); + it('Should get epochAdjustment from cache', (done) => { + let counter = 0; + const repositoryMock: NetworkRepository = mock(); + const expectedepochAdjustment = 1573430400; + const body: NetworkConfigurationDTO = { + network: { + identifier: 'public-test', + nemesisSignerPublicKey: 'E3F04CA92250B49679EBEF98FAC87C1CECAC7E7491ECBB2307DF1AD65BED57FD', + generationHashSeed: 'AE6488282F9C09457F017BE5EE26387B21EB15CF32D6DA1E9846C25E00828329', + epochAdjustment: '1573430400s', + }, + chain: {}, + plugins: {}, + }; + const observableOfNetworkProperties = observableOf(body).pipe( + map((v) => { + counter++; + return v; + }), + ); + when(repositoryMock.getNetworkProperties()).thenReturn(observableOfNetworkProperties); + + expect(observableOfNetworkProperties).to.be.equals(observableOfNetworkProperties); + + const repositoryFactory = new (class RepositoryFactoryHttpForTest extends RepositoryFactoryHttp { + createNetworkRepository(): NetworkRepository { + return instance(repositoryMock); + } + })('http://localhost:3000', { + generationHash: 'testHash', + networkType: 152, + }); + + expect(counter).to.be.equals(0); + repositoryFactory.getEpochAdjustment().subscribe((epoch) => { + expect(counter).to.be.equals(1); + expect(epoch.seconds()).to.be.equals(expectedepochAdjustment); + repositoryFactory.getEpochAdjustment().subscribe((network) => { + expect(counter).to.be.equals(1); + expect(network.seconds()).to.be.equals(expectedepochAdjustment); + done(); + }); + }); + }); + it('Should get NetworkType from memory', (done) => { let counter = 0; @@ -158,6 +205,7 @@ describe('RepositoryFactory', () => { })('http://localhost:3000', { networkType: expectedNetworkType, generationHash: 'testHash', + epochAdjustment: 1573430400, }); expect(counter).to.be.equals(0); @@ -172,6 +220,53 @@ describe('RepositoryFactory', () => { }); }); + it('Should get epochAdjustment from memory', (done) => { + let counter = 0; + + const repositoryMock: NetworkRepository = mock(); + const expectedepochAdjustment = 1573430400; + const body: NetworkConfigurationDTO = { + network: { + identifier: 'public-test', + nemesisSignerPublicKey: 'E3F04CA92250B49679EBEF98FAC87C1CECAC7E7491ECBB2307DF1AD65BED57FD', + generationHashSeed: 'AE6488282F9C09457F017BE5EE26387B21EB15CF32D6DA1E9846C25E00828329', + epochAdjustment: '1573430400s', + }, + chain: {}, + plugins: {}, + }; + const observableOfNetworkProperties = observableOf(body).pipe( + map((v) => { + counter++; + return v; + }), + ); + when(repositoryMock.getNetworkProperties()).thenReturn(observableOfNetworkProperties); + + expect(observableOfNetworkProperties).to.be.equals(observableOfNetworkProperties); + + const repositoryFactory = new (class RepositoryFactoryHttpForTest extends RepositoryFactoryHttp { + createNetworkRepository(): NetworkRepository { + return instance(repositoryMock); + } + })('http://localhost:3000', { + networkType: 152, + generationHash: 'testHash', + epochAdjustment: 1573430400, + }); + + expect(counter).to.be.equals(0); + repositoryFactory.getEpochAdjustment().subscribe((networkType) => { + expect(counter).to.be.equals(0); + expect(networkType.seconds()).to.be.equals(expectedepochAdjustment); + repositoryFactory.getEpochAdjustment().subscribe((network) => { + expect(counter).to.be.equals(0); + expect(network.seconds()).to.be.equals(expectedepochAdjustment); + done(); + }); + }); + }); + it('Should create listener object using injected ws', () => { class WebSocketMock { constructor(public readonly url: string) {} diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index 4de04b5f2c..a4fa7413b0 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -54,17 +54,18 @@ import { VotingKeyLinkTransaction } from '../../src/model/transaction/VotingKeyL import { VrfKeyLinkTransaction } from '../../src/model/transaction/VrfKeyLinkTransaction'; import { UInt64 } from '../../src/model/UInt64'; import { TestingAccount } from '../conf/conf.spec'; +import { Duration } from 'js-joda'; describe('SerializeTransactionToJSON', () => { let account: Account; - + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -79,7 +80,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -96,7 +97,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -113,7 +114,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -131,7 +132,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -148,7 +149,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -162,7 +163,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -181,7 +182,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, false), @@ -200,7 +201,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -215,7 +216,7 @@ describe('SerializeTransactionToJSON', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -232,7 +233,7 @@ describe('SerializeTransactionToJSON', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -250,7 +251,7 @@ describe('SerializeTransactionToJSON', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -268,7 +269,7 @@ describe('SerializeTransactionToJSON', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -285,7 +286,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -293,7 +294,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -307,7 +308,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -315,7 +316,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -329,10 +330,10 @@ describe('SerializeTransactionToJSON', () => { it('should create LockFundTransaction', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -347,7 +348,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -360,7 +361,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -373,7 +374,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -386,7 +387,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -400,7 +401,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VotingKeyLinkTransaction', () => { const votingKey = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, 1, 3, diff --git a/test/infrastructure/TransactionHttp.spec.ts b/test/infrastructure/TransactionHttp.spec.ts index 92a6cd99b5..309c85e715 100644 --- a/test/infrastructure/TransactionHttp.spec.ts +++ b/test/infrastructure/TransactionHttp.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { BlockDTO, BlockInfoDTO, @@ -58,32 +59,33 @@ describe('TransactionHttp', () => { cosignature.signerPublicKey = 'signerPubKey'; cosignature.signature = 'signature'; cosignature.version = '0'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { transactionRoutesApi = mock(); blockRoutesApi = mock(); - transactionHttp = new TransactionHttp(NIS2_URL); + transactionHttp = new TransactionHttp(NIS2_URL, 1573430400); (transactionHttp as object)['transactionRoutesApi'] = instance(transactionRoutesApi); (transactionHttp as object)['blockRoutesApi'] = instance(blockRoutesApi); }); it('should return an error when a non aggregate transaction bonded is announced via announceAggregateBonded method', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), NetworkType.MIJIN_TEST, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTx = account.sign(aggTx, generationHash); - const trnsHttp = new TransactionHttp(NIS2_URL); + const trnsHttp = new TransactionHttp(NIS2_URL, 1573430400); expect(() => { trnsHttp.announceAggregateBonded(signedTx).toPromise().then(); }).to.throw(Error, 'Only Transaction Type 0x4241 is allowed for announce aggregate bonded'); @@ -388,7 +390,7 @@ describe('TransactionHttp', () => { it('Test announce', async () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -407,7 +409,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -415,7 +417,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -495,7 +497,7 @@ describe('TransactionHttp', () => { it('announce - Error', async () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -515,7 +517,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -523,7 +525,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/infrastructure/TransactionStatusHttp.spec.ts b/test/infrastructure/TransactionStatusHttp.spec.ts index 0e08ae4620..e64494ad8c 100644 --- a/test/infrastructure/TransactionStatusHttp.spec.ts +++ b/test/infrastructure/TransactionStatusHttp.spec.ts @@ -29,10 +29,11 @@ import { NIS2_URL } from '../conf/conf.spec'; describe('TransactionStatusHttp', () => { let transactionStatusRoutesApi: TransactionStatusRoutesApi; let transactionStatusHttp: TransactionStatusHttp; + const epochAdjustment = 1573430400; before(() => { transactionStatusRoutesApi = mock(); - transactionStatusHttp = new TransactionStatusHttp(NIS2_URL); + transactionStatusHttp = new TransactionStatusHttp(NIS2_URL, epochAdjustment); (transactionStatusHttp as object)['transactionStatusRoutesApi'] = instance(transactionStatusRoutesApi); }); diff --git a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 24767e1f97..4e775c4f3a 100644 --- a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -195,7 +195,7 @@ describe('CreateTransactionFromDTO', () => { const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal('test-message'); - expect(transferTransaction.deadline.value).to.be.equal(LocalDateTime.MIN); + expect(transferTransaction.deadline.adjustedValue).to.be.equal(LocalDateTime.MIN.second()); expect(transferTransaction.maxFee.toString()).to.be.equal('0'); }); }); diff --git a/test/model/account/Account.spec.ts b/test/model/account/Account.spec.ts index 5041c6bf36..b893c3d8a4 100644 --- a/test/model/account/Account.spec.ts +++ b/test/model/account/Account.spec.ts @@ -25,6 +25,7 @@ import { AggregateTransaction } from '../../../src/model/transaction/AggregateTr import { CosignatureTransaction } from '../../../src/model/transaction/CosignatureTransaction'; import { CosignatureSignedTransaction } from '../../../src/model/transaction/CosignatureSignedTransaction'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; +import { Duration } from 'js-joda'; describe('Account', () => { const accountInformation = { @@ -33,6 +34,7 @@ describe('Account', () => { publicKey: '9801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B6'.toUpperCase(), }; + const epochAdjustment = Duration.ofSeconds(1573430400); it('should be created via private key', () => { const account = Account.createFromPrivateKey(accountInformation.privateKey, NetworkType.MIJIN_TEST); expect(account.publicKey).to.be.equal(accountInformation.publicKey); @@ -72,14 +74,14 @@ describe('Account', () => { const account2 = Account.generateNewAccount(NetworkType.TEST_NET); const generationHash = 'C422CC3C9257A1568036E1726E64EB5923C8363A13D4344F9E66CD89C8789BC7'; const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account2.address, [sendAmount], PlainMessage.create('payout'), NetworkType.TEST_NET, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [backAmount], PlainMessage.create('payout'), @@ -88,7 +90,7 @@ describe('Account', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], NetworkType.TEST_NET, [], diff --git a/test/model/message/EncryptedMessage.spec.ts b/test/model/message/EncryptedMessage.spec.ts index d4057da366..d98315ef24 100644 --- a/test/model/message/EncryptedMessage.spec.ts +++ b/test/model/message/EncryptedMessage.spec.ts @@ -21,6 +21,7 @@ import { NetworkType } from '../../../src/model/network/NetworkType'; import { Deadline } from '../../../src/model/transaction/Deadline'; import { TransferTransaction } from '../../../src/model/transaction/TransferTransaction'; import { NetworkCurrencyLocal } from '../../../src/model/mosaic/NetworkCurrencyLocal'; +import { Duration } from 'js-joda'; describe('EncryptedMessage', () => { let sender: Account; @@ -28,6 +29,7 @@ describe('EncryptedMessage', () => { let sender_nis: Account; let recipient_nis: Account; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( @@ -63,7 +65,7 @@ describe('EncryptedMessage', () => { it('should return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), recipient.address, [NetworkCurrencyLocal.createAbsolute(1)], sender.encryptMessage('Testing simple transfer', recipient.publicAccount), diff --git a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts index d1b592e1c6..25c4c653cd 100644 --- a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts +++ b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Account } from '../../../src/model/account/Account'; import { MessageType } from '../../../src/model/message/MessageType'; import { PersistentHarvestingDelegationMessage } from '../../../src/model/message/PersistentHarvestingDelegationMessage'; @@ -28,6 +29,7 @@ describe('PersistentHarvestingDelegationMessage', () => { let recipient_nis: Account; const signingPrivateKey = 'F0AB1010EFEE19EE5373719881DF5123C13E643C519655F7E97347BFF77175BF'; const vrfPrivateKey = '800F35F1CC66C2B62CE9DD9F31003B9B3E5C7A2F381FB8952A294277A1015D83'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( @@ -82,7 +84,7 @@ describe('PersistentHarvestingDelegationMessage', () => { it('return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), signingPrivateKey, vrfPrivateKey, recipient.publicKey, diff --git a/test/model/transaction/AccountKeyLinkTransaction.spec.ts b/test/model/transaction/AccountKeyLinkTransaction.spec.ts index 4153ea50a0..da3c7698bd 100644 --- a/test/model/transaction/AccountKeyLinkTransaction.spec.ts +++ b/test/model/transaction/AccountKeyLinkTransaction.spec.ts @@ -24,17 +24,19 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('AccountKeyLinkTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('AccountKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with unlink action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('AccountKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for AccountKeyLinkTransaction byte size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -107,7 +109,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create payload size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +122,7 @@ describe('AccountKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -132,7 +134,12 @@ describe('AccountKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = AccountKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = AccountKeyLinkTransaction.create( + Deadline.create(epochAdjustment), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/AccountMetadataTransaction.spec.ts b/test/model/transaction/AccountMetadataTransaction.spec.ts index 067d5fb6b4..bcfc8c3cb7 100644 --- a/test/model/transaction/AccountMetadataTransaction.spec.ts +++ b/test/model/transaction/AccountMetadataTransaction.spec.ts @@ -27,17 +27,19 @@ import { TransactionType } from '../../../src/model/transaction/TransactionType' import { deepEqual } from 'assert'; import { Address } from '../../../src/model/account/Address'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; +import { Duration } from 'js-joda'; describe('AccountMetadataTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -51,7 +53,7 @@ describe('AccountMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -66,7 +68,7 @@ describe('AccountMetadataTransaction', () => { it('should create and sign an AccountMetadataTransaction object', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -84,7 +86,7 @@ describe('AccountMetadataTransaction', () => { describe('size', () => { it('should return 174 for AccountMetadataTransaction byte size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -101,7 +103,7 @@ describe('AccountMetadataTransaction', () => { it('should set payload size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -118,7 +120,7 @@ describe('AccountMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -137,7 +139,7 @@ describe('AccountMetadataTransaction', () => { it('should resolve alias', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -153,7 +155,7 @@ describe('AccountMetadataTransaction', () => { it('Notify Account', () => { const tx = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -175,7 +177,7 @@ describe('AccountMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index 7aeb6d9761..738b332fc4 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -31,10 +31,12 @@ import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; +import { Duration } from 'js-joda'; describe('AccountRestrictionTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -67,7 +69,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 160 for AccountAddressRestrictionTransaction transaction byte size with 1 modification', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -81,7 +83,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 144 for AccountMosaicRestrictionTransaction transaction byte size with 1 modification', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -92,7 +94,7 @@ describe('AccountRestrictionTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -105,7 +107,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 138 for AccountOperationRestrictionTransaction transaction byte size with 1 modification', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -117,7 +119,7 @@ describe('AccountRestrictionTransaction', () => { it('should default maxFee field be set to 0', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -131,7 +133,7 @@ describe('AccountRestrictionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -146,7 +148,7 @@ describe('AccountRestrictionTransaction', () => { it('should create allow incmoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -163,7 +165,7 @@ describe('AccountRestrictionTransaction', () => { it('should create mosaic restriction transaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -178,7 +180,7 @@ describe('AccountRestrictionTransaction', () => { it('should create operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -193,7 +195,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); let addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -207,7 +209,7 @@ describe('AccountRestrictionTransaction', () => { ); addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [address], [], @@ -224,7 +226,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; let operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -236,7 +238,7 @@ describe('AccountRestrictionTransaction', () => { expect(signedTransaction.payload.substring(256, signedTransaction.payload.length)).to.be.equal('04400100000000004E42'); operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [operation], [], @@ -251,7 +253,7 @@ describe('AccountRestrictionTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -267,7 +269,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [], [address], @@ -287,7 +289,7 @@ describe('AccountRestrictionTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [alias], [], @@ -303,7 +305,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [], [alias], diff --git a/test/model/transaction/AddressAliasTransaction.spec.ts b/test/model/transaction/AddressAliasTransaction.spec.ts index 8a6bc3b288..707d70c5d1 100644 --- a/test/model/transaction/AddressAliasTransaction.spec.ts +++ b/test/model/transaction/AddressAliasTransaction.spec.ts @@ -26,10 +26,12 @@ import { Deadline } from '../../../src/model/transaction/Deadline'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { AliasTransaction } from '../../../src/model/model'; +import { Duration } from 'js-joda'; describe('AddressAliasTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -38,7 +40,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -53,7 +55,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -69,7 +71,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -92,7 +94,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AliasTransaction.createForAddress( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -116,7 +118,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -130,7 +132,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -146,7 +148,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -158,7 +160,13 @@ describe('AddressAliasTransaction', () => { it('Notify Account', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); - const tx = AddressAliasTransaction.create(Deadline.create(), AliasAction.Link, namespaceId, address, NetworkType.MIJIN_TEST); + const tx = AddressAliasTransaction.create( + Deadline.create(epochAdjustment), + AliasAction.Link, + namespaceId, + address, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index 49df7dbcdb..829ac08dc1 100644 --- a/test/model/transaction/AggregateTransaction.spec.ts +++ b/test/model/transaction/AggregateTransaction.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO'; @@ -58,6 +58,7 @@ describe('AggregateTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +81,7 @@ describe('AggregateTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -88,7 +89,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -100,7 +101,7 @@ describe('AggregateTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -108,7 +109,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -121,7 +122,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -129,7 +130,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -144,14 +145,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [registerNamespaceTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -168,7 +169,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -178,7 +179,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -196,7 +197,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -204,7 +205,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -221,7 +222,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [ @@ -232,7 +233,7 @@ describe('AggregateTransaction', () => { NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -249,14 +250,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with different cosignatories', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(MultisigAccount.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -277,7 +278,7 @@ describe('AggregateTransaction', () => { it('should createBonded an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -285,7 +286,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -391,20 +392,20 @@ describe('AggregateTransaction', () => { }); it("should have type 0x4141 when it's complete", () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); expect(aggregateTransaction.type).to.be.equal(0x4141); }); it("should have type 0x4241 when it's bonded", () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST); expect(aggregateTransaction.type).to.be.equal(0x4241); }); it('should throw exception when adding an aggregated transaction as inner transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -412,7 +413,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -420,7 +421,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [aggregateTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -437,21 +438,21 @@ describe('AggregateTransaction', () => { const accountCarol = Cosignatory2Account; const AtoBTx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), accountBob.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const BtoATx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), accountAlice.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); const CtoATx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), accountAlice.address, [], PlainMessage.create('c to a'), @@ -460,7 +461,7 @@ describe('AggregateTransaction', () => { // 01. Alice creates the aggregated tx and sign it, Then payload send to Bob & Carol const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [ AtoBTx.toAggregate(accountAlice.publicAccount), BtoATx.toAggregate(accountBob.publicAccount), @@ -507,21 +508,21 @@ describe('AggregateTransaction', () => { it('Should be able to add innertransactions to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const transferTx2 = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -538,14 +539,14 @@ describe('AggregateTransaction', () => { it('Should be able to add cosignatures to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -570,14 +571,14 @@ describe('AggregateTransaction', () => { describe('size', () => { it('should return 268 for AggregateTransaction byte size with TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -587,14 +588,14 @@ describe('AggregateTransaction', () => { }); it('should set payload size', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -607,7 +608,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -615,7 +616,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -628,7 +629,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -637,7 +638,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -683,14 +684,14 @@ describe('AggregateTransaction', () => { it('Notify Account', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account.address, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -707,14 +708,14 @@ describe('AggregateTransaction', () => { it('Notify Account with alias', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/model/transaction/CosignatureTransaction.spec.ts b/test/model/transaction/CosignatureTransaction.spec.ts index 116dd6be93..aabaaf5bf4 100644 --- a/test/model/transaction/CosignatureTransaction.spec.ts +++ b/test/model/transaction/CosignatureTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO'; import { Account } from '../../../src/model/account/Account'; import { PlainMessage } from '../../../src/model/message/PlainMessage'; @@ -28,6 +29,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('CosignatureTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -106,7 +108,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with transaction payload', () => { const txPayload = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -122,7 +124,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with provided transactionHash', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -130,7 +132,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -149,7 +151,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction to throw', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -157,7 +159,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/model/transaction/Deadline.spec.ts b/test/model/transaction/Deadline.spec.ts index b6bb7f93be..bcb8c0d14c 100644 --- a/test/model/transaction/Deadline.spec.ts +++ b/test/model/transaction/Deadline.spec.ts @@ -17,30 +17,27 @@ import { expect } from 'chai'; import { ChronoUnit, Instant, LocalDateTime, ZoneId } from 'js-joda'; import { Deadline } from '../../../src/model/transaction/Deadline'; +import { Duration } from 'js-joda'; describe('Deadline', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); + it('should createComplete timestamp today', () => { - const deadline = Deadline.create(); + const deadline = Deadline.create(epochAdjustment); // avoid SYSTEM and UTC differences const networkTimeStamp = new Date().getTime(); const timestampLocal = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); const reproducedDate = timestampLocal.plus(2, ChronoUnit.HOURS); - expect(deadline.value.dayOfMonth()).to.be.equal(reproducedDate.dayOfMonth()); - expect(deadline.value.monthValue()).to.be.equal(reproducedDate.monthValue()); - expect(deadline.value.year()).to.be.equal(reproducedDate.year()); + expect(deadline.toLocalDateTime(epochAdjustment).dayOfMonth()).to.be.equal(reproducedDate.dayOfMonth()); + expect(deadline.toLocalDateTime(epochAdjustment).monthValue()).to.be.equal(reproducedDate.monthValue()); + expect(deadline.toLocalDateTime(epochAdjustment).year()).to.be.equal(reproducedDate.year()); }); it('should throw error deadline smaller than timeStamp', () => { expect(() => { - Deadline.create(-3); - }).to.throw(Error); - }); - - it('should throw error deadline greater than 24h', () => { - expect(() => { - Deadline.create(2, ChronoUnit.DAYS); + Deadline.create(epochAdjustment, -3); }).to.throw(Error); }); @@ -53,11 +50,11 @@ describe('Deadline', () => { it('should createComplete empty deadline', () => { const deadline = Deadline.createEmtpy(); - expect(deadline.value).to.be.equal(LocalDateTime.MIN); + expect(deadline.adjustedValue).to.be.equal(LocalDateTime.MIN.second()); }); it('make sure epochAdjustment is correct', () => { - const epochAdjustment = new Date(Deadline.timestampNemesisBlock * 1000); + const epochAdjustment = new Date(1573430400 * 1000); expect(epochAdjustment.getUTCFullYear()).to.be.equal(2019); expect(epochAdjustment.getUTCMonth() + 1).to.be.equal(11); @@ -66,4 +63,26 @@ describe('Deadline', () => { expect(epochAdjustment.getUTCMinutes()).to.be.equal(0); expect(epochAdjustment.toUTCString()).to.be.equal('Mon, 11 Nov 2019 00:00:00 GMT'); }); + + it('should create local date time - default time zone', () => { + const deadline = Deadline.createFromDTO('1'); + const datetime = deadline.toLocalDateTime(epochAdjustment); + expect(datetime.year()).to.be.equal(2019); + expect(datetime.month().value()).to.be.equal(11); + expect(datetime.dayOfMonth()).to.be.equal(11); + expect(datetime.hour()).to.be.equal(0); + expect(datetime.second()).to.be.equal(0); + expect(datetime.minute()).to.be.equal(0); + }); + + it('should create local date time - customer time zone', () => { + const deadline = Deadline.createFromDTO('1'); + const datetime = deadline.toLocalDateTimeGivenTimeZone(epochAdjustment, ZoneId.of('UTC-2')); + expect(datetime.year()).to.be.equal(2019); + expect(datetime.month().value()).to.be.equal(11); + expect(datetime.dayOfMonth()).to.be.equal(10); + expect(datetime.hour()).to.be.equal(22); + expect(datetime.second()).to.be.equal(0); + expect(datetime.minute()).to.be.equal(0); + }); }); diff --git a/test/model/transaction/HashLockTransaction.spec.ts b/test/model/transaction/HashLockTransaction.spec.ts index b13bc6b8d7..b361138e11 100644 --- a/test/model/transaction/HashLockTransaction.spec.ts +++ b/test/model/transaction/HashLockTransaction.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { NetworkCurrencyLocal } from '../../../src/model/mosaic/NetworkCurrencyLocal'; import { NetworkType } from '../../../src/model/network/NetworkType'; @@ -26,11 +27,12 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('HashLockTransaction', () => { const account = TestingAccount; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -43,11 +45,11 @@ describe('HashLockTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { HashLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -57,10 +59,10 @@ describe('HashLockTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = HashLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/LockFundsTransaction.spec.ts b/test/model/transaction/LockFundsTransaction.spec.ts index 408ea816e9..d36ea5104f 100644 --- a/test/model/transaction/LockFundsTransaction.spec.ts +++ b/test/model/transaction/LockFundsTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { deepEqual } from 'assert'; import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { Mosaic } from '../../../src/model/mosaic/Mosaic'; @@ -40,6 +41,7 @@ describe('LockFundsTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -54,10 +56,10 @@ describe('LockFundsTransaction', () => { }); it('should default maxFee field be set to 0', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -70,10 +72,10 @@ describe('LockFundsTransaction', () => { }); it('should filled maxFee override transaction maxFee', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -86,10 +88,10 @@ describe('LockFundsTransaction', () => { }); it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -101,11 +103,11 @@ describe('LockFundsTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -115,10 +117,10 @@ describe('LockFundsTransaction', () => { }); it('should create and sign LockFundsTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -133,10 +135,15 @@ describe('LockFundsTransaction', () => { describe('size', () => { it('should return 184 for LockFundsTransaction transaction byte size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(epochAdjustment), + [], + NetworkType.MIJIN_TEST, + [], + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -146,10 +153,15 @@ describe('LockFundsTransaction', () => { }); it('should set payload size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(epochAdjustment), + [], + NetworkType.MIJIN_TEST, + [], + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -161,10 +173,10 @@ describe('LockFundsTransaction', () => { }); it('Test set maxFee using multiplier', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -177,7 +189,7 @@ describe('LockFundsTransaction', () => { }); it('Test resolveAlias can resolve', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = new LockFundsTransaction( NetworkType.MIJIN_TEST, @@ -199,10 +211,10 @@ describe('LockFundsTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts index 0c97a7a916..c4ce9023ba 100644 --- a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; @@ -39,6 +40,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -59,7 +61,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction object and sign', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), account.address, @@ -83,7 +85,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction use mosaic alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), namespacId, UInt64.fromUint(1), account.address, @@ -108,7 +110,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), namespacId, @@ -131,7 +133,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should format targetAddress payload with 8 bytes binary namespaceId - targetAddressToString', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), @@ -152,7 +154,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('Test set maxFee using multiplier', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), diff --git a/test/model/transaction/MosaicAliasTransaction.spec.ts b/test/model/transaction/MosaicAliasTransaction.spec.ts index fbf2586a6e..787b8c9aeb 100644 --- a/test/model/transaction/MosaicAliasTransaction.spec.ts +++ b/test/model/transaction/MosaicAliasTransaction.spec.ts @@ -29,10 +29,12 @@ import { deepEqual } from 'assert'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTransactionBuilder'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; import { AliasTransaction } from '../../../src/model/transaction/AliasTransaction'; +import { Duration } from 'js-joda'; describe('MosaicAliasTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -41,7 +43,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -56,7 +58,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -72,7 +74,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -96,7 +98,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = AliasTransaction.createForMosaic( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -121,7 +123,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -134,7 +136,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -150,7 +152,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -166,7 +168,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -180,7 +182,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -199,7 +201,13 @@ describe('MosaicAliasTransaction', () => { it('Notify Account', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); - const tx = MosaicAliasTransaction.create(Deadline.create(), AliasAction.Link, namespaceId, mosaicId, NetworkType.MIJIN_TEST); + const tx = MosaicAliasTransaction.create( + Deadline.create(epochAdjustment), + AliasAction.Link, + namespaceId, + mosaicId, + NetworkType.MIJIN_TEST, + ); Object.assign(tx, { signer: account.publicAccount }); expect(tx.shouldNotifyAccount(account.address)).to.be.true; diff --git a/test/model/transaction/MosaicDefinitionTransaction.spec.ts b/test/model/transaction/MosaicDefinitionTransaction.spec.ts index 3c8f95ad40..1b1e6ecef3 100644 --- a/test/model/transaction/MosaicDefinitionTransaction.spec.ts +++ b/test/model/transaction/MosaicDefinitionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicFlags } from '../../../src/model/mosaic/MosaicFlags'; @@ -29,13 +30,14 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('MosaicDefinitionTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -50,7 +52,7 @@ describe('MosaicDefinitionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -66,7 +68,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 7', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -91,7 +93,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -117,7 +119,7 @@ describe('MosaicDefinitionTransaction', () => { describe('size', () => { it('should return 150 for MosaicDefinition transaction byte size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -130,7 +132,7 @@ describe('MosaicDefinitionTransaction', () => { }); it('should set payload size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -146,7 +148,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -169,7 +171,7 @@ describe('MosaicDefinitionTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -185,7 +187,7 @@ describe('MosaicDefinitionTransaction', () => { it('Notify Account', () => { const tx = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), diff --git a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts index 22c0d3abef..fd468036cb 100644 --- a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicId } from '../../../src/model/mosaic/MosaicId'; @@ -38,6 +39,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -55,7 +57,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -85,7 +87,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), namespacId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -119,7 +121,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -149,7 +151,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -195,7 +197,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const tx = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), diff --git a/test/model/transaction/MosaicMetadataTransaction.spec.ts b/test/model/transaction/MosaicMetadataTransaction.spec.ts index 9be4a08330..f9ef79a171 100644 --- a/test/model/transaction/MosaicMetadataTransaction.spec.ts +++ b/test/model/transaction/MosaicMetadataTransaction.spec.ts @@ -33,6 +33,7 @@ import { TestingAccount } from '../../conf/conf.spec'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript'; import { Address } from '../../../src/model/account/Address'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; +import { Duration } from 'js-joda'; describe('MosaicMetadataTransaction', () => { let account: Account; @@ -40,6 +41,7 @@ describe('MosaicMetadataTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -55,7 +57,7 @@ describe('MosaicMetadataTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -70,7 +72,7 @@ describe('MosaicMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -86,7 +88,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -105,7 +107,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object using alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), namespacId, @@ -124,7 +126,7 @@ describe('MosaicMetadataTransaction', () => { describe('size', () => { it('should return 182 for MosaicMetadataTransaction byte size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -138,7 +140,7 @@ describe('MosaicMetadataTransaction', () => { it('should set payload size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -154,7 +156,7 @@ describe('MosaicMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -192,7 +194,7 @@ describe('MosaicMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -212,7 +214,7 @@ describe('MosaicMetadataTransaction', () => { it('Notify Account', () => { const tx = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -234,7 +236,7 @@ describe('MosaicMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), diff --git a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts index f24d4c1a9b..e69dfec814 100644 --- a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts +++ b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicId } from '../../../src/model/mosaic/MosaicId'; @@ -38,6 +39,7 @@ describe('MosaicSupplyChangeTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -54,7 +56,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -68,7 +70,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -83,7 +85,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should createComplete an MosaicSupplyChangeTransaction object and sign it', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -107,7 +109,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should return 145 for MosaicSupplyChange transaction byte size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -119,7 +121,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -134,7 +136,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -167,7 +169,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Notify Account', () => { const tx = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new MosaicId([2262289484, 3405110546]), MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), diff --git a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts index f6db0fbd44..5a817d2912 100644 --- a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts +++ b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts @@ -24,6 +24,7 @@ import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; +import { Duration } from 'js-joda'; describe('MultisigAccountModificationTransaction', () => { let account: Account; @@ -36,13 +37,14 @@ describe('MultisigAccountModificationTransaction', () => { 'B1B5581FC81A6970DEE418D2C2978F2724228B7B36C5C6DF71B0162BB04778B4', NetworkType.MIJIN_TEST, ); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -56,7 +58,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -71,7 +73,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should createComplete an MultisigAccountModificationTransaction object and sign it', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -96,7 +98,7 @@ describe('MultisigAccountModificationTransaction', () => { describe('size', () => { it('should return 160 for MultisigAccountModificationTransaction transaction byte size with 1 modification', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -110,7 +112,7 @@ describe('MultisigAccountModificationTransaction', () => { }); it('should set payload size', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -127,7 +129,7 @@ describe('MultisigAccountModificationTransaction', () => { it('Test set maxFee using multiplier', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -141,7 +143,14 @@ describe('MultisigAccountModificationTransaction', () => { }); it('Notify Account', () => { - const txAddition = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [address1], [], NetworkType.MIJIN_TEST); + const txAddition = MultisigAccountModificationTransaction.create( + Deadline.create(epochAdjustment), + 1, + 1, + [address1], + [], + NetworkType.MIJIN_TEST, + ); let canNotify = txAddition.shouldNotifyAccount(address1, []); expect(canNotify).to.be.true; @@ -152,7 +161,14 @@ describe('MultisigAccountModificationTransaction', () => { Object.assign(txAddition, { signer: account.publicAccount }); expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; - const txDeletion = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [], [address1], NetworkType.MIJIN_TEST); + const txDeletion = MultisigAccountModificationTransaction.create( + Deadline.create(epochAdjustment), + 1, + 1, + [], + [address1], + NetworkType.MIJIN_TEST, + ); let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, []); expect(canNotifyDeletion).to.be.true; @@ -167,7 +183,14 @@ describe('MultisigAccountModificationTransaction', () => { it('Notify Account with alias', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); - const txAddition = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [alias], [], NetworkType.MIJIN_TEST); + const txAddition = MultisigAccountModificationTransaction.create( + Deadline.create(epochAdjustment), + 1, + 1, + [alias], + [], + NetworkType.MIJIN_TEST, + ); let canNotify = txAddition.shouldNotifyAccount(address1, [alias]); expect(canNotify).to.be.true; @@ -181,7 +204,14 @@ describe('MultisigAccountModificationTransaction', () => { Object.assign(txAddition, { signer: account.publicAccount }); expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; - const txDeletion = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [], [alias], NetworkType.MIJIN_TEST); + const txDeletion = MultisigAccountModificationTransaction.create( + Deadline.create(epochAdjustment), + 1, + 1, + [], + [alias], + NetworkType.MIJIN_TEST, + ); let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, [alias]); expect(canNotifyDeletion).to.be.true; diff --git a/test/model/transaction/NamespaceMetadataTransaction.spec.ts b/test/model/transaction/NamespaceMetadataTransaction.spec.ts index bfdce1a49a..e366bee763 100644 --- a/test/model/transaction/NamespaceMetadataTransaction.spec.ts +++ b/test/model/transaction/NamespaceMetadataTransaction.spec.ts @@ -27,17 +27,19 @@ import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTr import { TransactionType } from '../../../src/model/transaction/TransactionType'; import { deepEqual } from 'assert'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('NamespaceMetadataTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -52,7 +54,7 @@ describe('NamespaceMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -68,7 +70,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create and sign an NamespaceMetadataTransaction object', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -87,7 +89,7 @@ describe('NamespaceMetadataTransaction', () => { describe('size', () => { it('should return 182 for NamespaceMetadataTransaction byte size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -101,7 +103,7 @@ describe('NamespaceMetadataTransaction', () => { it('should set payload size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -117,7 +119,7 @@ describe('NamespaceMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -133,7 +135,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -153,7 +155,7 @@ describe('NamespaceMetadataTransaction', () => { it('should resolve alias', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -169,7 +171,7 @@ describe('NamespaceMetadataTransaction', () => { it('Notify Account', () => { const tx = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -191,7 +193,7 @@ describe('NamespaceMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), alias, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), diff --git a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts index ffb4b927fa..244e35014f 100644 --- a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts +++ b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; @@ -27,13 +28,14 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('NamespaceRegistrationTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -45,7 +47,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -58,7 +60,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an root NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -76,7 +78,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -91,7 +93,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it - ParentId', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', new NamespaceId([929036875, 2226345261]), NetworkType.MIJIN_TEST, @@ -107,7 +109,7 @@ describe('NamespaceRegistrationTransaction', () => { describe('size', () => { it('should return 165 for NamespaceRegistrationTransaction with name of 19 bytes', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -117,7 +119,7 @@ describe('NamespaceRegistrationTransaction', () => { }); it('should set payload size', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -130,7 +132,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Test set maxFee using multiplier', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -143,7 +145,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Notify Account', () => { const tx = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, diff --git a/test/model/transaction/NodeKeyLinkTransaction.spec.ts b/test/model/transaction/NodeKeyLinkTransaction.spec.ts index ae3cb3efef..f93711619f 100644 --- a/test/model/transaction/NodeKeyLinkTransaction.spec.ts +++ b/test/model/transaction/NodeKeyLinkTransaction.spec.ts @@ -24,17 +24,19 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('NodeKeyLinkTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('NodeKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with unlink action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('NodeKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for NodeKeyLinkTransaction byte size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -106,7 +108,7 @@ describe('NodeKeyLinkTransaction', () => { }); it('should set payload size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -119,7 +121,7 @@ describe('NodeKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -131,7 +133,12 @@ describe('NodeKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = NodeKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = NodeKeyLinkTransaction.create( + Deadline.create(epochAdjustment), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts index ee1333fa21..6445821b0d 100644 --- a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts +++ b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; import { MessageMarker } from '../../../src/model/message/MessageMarker'; @@ -31,6 +32,7 @@ describe('PersistentDelegationRequestTransaction', () => { const recipientPublicKey = '9DBF67474D6E1F8B131B4EB1F5BA0595AFFAE1123607BC1048F342193D7E669F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const messageMarker = MessageMarker.PersistentDelegationUnlock; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; @@ -38,7 +40,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should default maxFee field be set to 0', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -51,7 +53,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -65,7 +67,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -92,7 +94,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should throw exception with invalid harvester publicKey (message)', () => { expect(() => { PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), 'abc', vrfPrivateKey, recipientPublicKey, diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index c39ce7c891..b39d968bd9 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -36,6 +36,7 @@ import { TransactionInfo } from '../../../src/model/transaction/TransactionInfo' import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import * as CryptoJS from 'crypto-js'; +import { Duration } from 'js-joda'; describe('SecretLockTransaction', () => { let account: Account; @@ -44,6 +45,7 @@ describe('SecretLockTransaction', () => { const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -65,7 +67,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -82,7 +84,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -100,7 +102,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -120,7 +122,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -139,7 +141,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -154,7 +156,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -174,7 +176,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -188,7 +190,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -208,7 +210,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -224,7 +226,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -240,7 +242,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -258,7 +260,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -278,7 +280,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -320,7 +322,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -342,7 +344,7 @@ describe('SecretLockTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index c2838b385e..a1c37a0834 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -34,12 +34,14 @@ import { TestingAccount } from '../../conf/conf.spec'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTransactionBuilder'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; import * as CryptoJS from 'crypto-js'; +import { Duration } from 'js-joda'; describe('SecretProofTransaction', () => { let account: Account; let statement: Statement; const unresolvedAddress = new NamespaceId('address'); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -56,7 +58,7 @@ describe('SecretProofTransaction', () => { it('should default maxFee field be set to 0', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -71,7 +73,7 @@ describe('SecretProofTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -87,7 +89,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Sha3_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -103,7 +105,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, 'non valid hash', account.address, @@ -116,7 +118,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_160 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_160, CryptoJS.RIPEMD160(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -132,7 +134,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_160, 'non valid hash', account.address, @@ -145,7 +147,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -161,7 +163,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, 'non valid hash', account.address, @@ -175,7 +177,7 @@ describe('SecretProofTransaction', () => { it('should return 219 for SecretProofTransaction with proof and secret both 32 bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -190,7 +192,7 @@ describe('SecretProofTransaction', () => { it('should create and sign SecretProof Transaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -209,7 +211,7 @@ describe('SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), recipientAddress, @@ -225,7 +227,7 @@ describe('SecretProofTransaction', () => { it('Test set maxFee using multiplier', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -242,7 +244,7 @@ describe('SecretProofTransaction', () => { const transferTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -264,7 +266,7 @@ describe('SecretProofTransaction', () => { const secretProofTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -286,7 +288,7 @@ describe('SecretProofTransaction', () => { it('should return secret bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -301,7 +303,7 @@ describe('SecretProofTransaction', () => { it('Notify Account', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const tx = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -322,7 +324,7 @@ describe('SecretProofTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index 006d0c0688..c4a983f095 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -32,10 +32,11 @@ import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; +import { Duration } from 'js-joda'; describe('Transaction', () => { let account: Account; - + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -76,7 +77,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -92,7 +93,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -106,7 +107,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -122,7 +123,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -138,7 +139,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -154,14 +155,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, new TransactionInfo(UInt64.fromUint(100), 1, 'id_hash', 'hash', 'hash'), ); expect(() => { - transaction.reapplyGiven(Deadline.create()); + transaction.reapplyGiven(Deadline.create(epochAdjustment)); }).to.throws("an Announced transaction can't be modified"); }); it('should return a new transaction', () => { @@ -169,13 +170,13 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); - const newTransaction = transaction.reapplyGiven(Deadline.create()); + const newTransaction = transaction.reapplyGiven(Deadline.create(epochAdjustment)); expect(newTransaction).to.not.equal(transaction); }); it('should overide deadline properly', () => { @@ -183,16 +184,16 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); - const newDeadline = Deadline.create(3); + const newDeadline = Deadline.create(epochAdjustment, 3); const newTransaction = transaction.reapplyGiven(newDeadline); - const equal = newTransaction.deadline.value.equals(transaction.deadline.value); - const after = newTransaction.deadline.value.isAfter(transaction.deadline.value); + const equal = newTransaction.deadline.adjustedValue === transaction.deadline.adjustedValue; + const after = newTransaction.deadline.adjustedValue > transaction.deadline.adjustedValue; expect(newTransaction.deadline).to.be.equal(newDeadline); expect(equal).to.be.equal(false); expect(after).to.be.equal(true); @@ -205,14 +206,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -227,7 +228,7 @@ describe('Transaction', () => { describe('Transaction serialize', () => { it('Should return serialized payload', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -247,7 +248,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -378,7 +379,7 @@ describe('Transaction', () => { it('is signed', () => { let tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index a3968bcfa6..0fdab15185 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -39,6 +39,7 @@ import { ResolutionType } from '../../../src/model/receipt/ResolutionType'; import { ReceiptSource } from '../../../src/model/receipt/ReceiptSource'; import { ResolutionEntry } from '../../../src/model/receipt/ResolutionEntry'; import { TransactionInfo } from '../../../src/model/transaction/TransactionInfo'; +import { Duration } from 'js-joda'; describe('TransferTransaction', () => { let account: Account; @@ -51,6 +52,7 @@ describe('TransferTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -73,7 +75,7 @@ describe('TransferTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -86,7 +88,7 @@ describe('TransferTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -100,7 +102,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it without mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -121,7 +123,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with empty message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], EmptyMessage, @@ -142,7 +144,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it with mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -165,7 +167,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with NamespaceId recipientAddress', () => { const addressAlias = new NamespaceId('nem.owner'); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -188,7 +190,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 24 bytes binary address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -205,7 +207,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 8 bytes binary namespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new NamespaceId('nem.owner'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -223,7 +225,7 @@ describe('TransferTransaction', () => { describe('size', () => { it('should return 180 for TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -235,7 +237,7 @@ describe('TransferTransaction', () => { it('should set payloadsize', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -249,7 +251,7 @@ describe('TransferTransaction', () => { it('should create TransferTransaction and sign using catbuffer-typescript', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -271,7 +273,7 @@ describe('TransferTransaction', () => { it('should create Transafer transaction for persistent harvesting delegation request transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -283,7 +285,7 @@ describe('TransferTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -304,7 +306,7 @@ describe('TransferTransaction', () => { it('should throw exception with mosaic provided when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -321,7 +323,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid message when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create('abc', vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -333,7 +335,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid private key when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -354,7 +356,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -383,7 +385,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -419,7 +421,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -433,7 +435,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier to throw', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -442,7 +444,7 @@ describe('TransferTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -475,7 +477,7 @@ describe('TransferTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -495,7 +497,7 @@ describe('TransferTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const namespaceId = new NamespaceId('test'); const canNotify = TransferTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), namespaceId, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/test/model/transaction/VotingKeyLinkTransaction.spec.ts b/test/model/transaction/VotingKeyLinkTransaction.spec.ts index f3c12381ee..66268b5415 100644 --- a/test/model/transaction/VotingKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VotingKeyLinkTransaction.spec.ts @@ -24,6 +24,7 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('VotingKeyLinkTransaction', () => { let account: Account; @@ -31,6 +32,7 @@ describe('VotingKeyLinkTransaction', () => { const startEpoch = 1; const endEpoch = 10; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; votingKey = '344B9146A1F8DBBD8AFC830A2AAB7A83692E73AD775159B811355B1D2C0C27120243B10A16D4B5001B2AF0ED456C82D0'; @@ -38,7 +40,7 @@ describe('VotingKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -54,7 +56,7 @@ describe('VotingKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -71,7 +73,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an votingKeyLinkTransaction object with link action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -93,7 +95,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an VotingKeyLinkTransaction object with unlink action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -116,7 +118,7 @@ describe('VotingKeyLinkTransaction', () => { describe('size', () => { it('should return 185 for VotingKeyLinkTransaction byte size', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -130,7 +132,7 @@ describe('VotingKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -145,7 +147,7 @@ describe('VotingKeyLinkTransaction', () => { it('Notify Account', () => { const tx = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, startEpoch, endEpoch, diff --git a/test/model/transaction/VrfKeyLinkTransaction.spec.ts b/test/model/transaction/VrfKeyLinkTransaction.spec.ts index d84b338420..d623afa913 100644 --- a/test/model/transaction/VrfKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VrfKeyLinkTransaction.spec.ts @@ -24,6 +24,7 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('VrfKeyLinkTransaction', () => { let account: Account; @@ -31,10 +32,11 @@ describe('VrfKeyLinkTransaction', () => { before(() => { account = TestingAccount; }); + const epochAdjustment = Duration.ofSeconds(1573430400); it('should default maxFee field be set to 0', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('VrfKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with unlink action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('VrfKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for VrfKeyLinkTransaction byte size', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -108,7 +110,7 @@ describe('VrfKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +122,12 @@ describe('VrfKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = VrfKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = VrfKeyLinkTransaction.create( + Deadline.create(epochAdjustment), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/service/AggregateTransactionService.spec.ts b/test/service/AggregateTransactionService.spec.ts index 3d157e7ddf..b49a93307c 100644 --- a/test/service/AggregateTransactionService.spec.ts +++ b/test/service/AggregateTransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { MultisigRepository } from '../../src/infrastructure/MultisigRepository'; @@ -91,6 +91,7 @@ describe('AggregateTransactionService', () => { NetworkType.MIJIN_TEST, ); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); function givenMultisig2AccountInfo(): MultisigAccountInfo { return new MultisigAccountInfo(multisig2.address, 2, 1, [multisig1.address, account1.address], []); @@ -188,7 +189,7 @@ describe('AggregateTransactionService', () => { * Expecting complete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -196,7 +197,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -221,7 +222,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but only got account1 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -229,7 +230,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -254,7 +255,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but got account4 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -262,7 +263,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -288,7 +289,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -296,7 +297,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -304,7 +305,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -329,7 +330,7 @@ describe('AggregateTransactionService', () => { * Expecting complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -337,7 +338,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -345,7 +346,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -367,7 +368,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const modifyMultisigTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), 1, 1, [], @@ -376,7 +377,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [modifyMultisigTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -398,7 +399,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -406,7 +407,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -430,7 +431,7 @@ describe('AggregateTransactionService', () => { * Bob sign */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -438,7 +439,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -468,7 +469,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -476,7 +477,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -484,7 +485,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -513,7 +514,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as incomplete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -521,7 +522,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -529,7 +530,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -551,7 +552,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -559,7 +560,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -581,7 +582,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -589,7 +590,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/service/MetadataTransactionservice.spec.ts b/test/service/MetadataTransactionservice.spec.ts index d3ec41a946..907ea7e41a 100644 --- a/test/service/MetadataTransactionservice.spec.ts +++ b/test/service/MetadataTransactionservice.spec.ts @@ -35,6 +35,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MetadataTransactionService } from '../../src/service/MetadataTransactionService'; import { TestingAccount } from '../conf/conf.spec'; import { Page } from '../../src/infrastructure/Page'; +import { Duration } from 'js-joda'; describe('MetadataTransactionService', () => { let account: Account; @@ -43,6 +44,7 @@ describe('MetadataTransactionService', () => { const value = 'TEST'; const deltaValue = 'dalta'; const targetIdHex = '941299B2B7E1291C'; + const epochAdjustment = Duration.ofSeconds(1573430400); function mockMetadata(type: MetadataType): Metadata { let targetId; @@ -111,7 +113,7 @@ describe('MetadataTransactionService', () => { it('should create AccountMetadataTransaction', (done) => { metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, key, @@ -134,7 +136,7 @@ describe('MetadataTransactionService', () => { it('should create MosaicMetadataTransaction', (done) => { metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -159,7 +161,7 @@ describe('MetadataTransactionService', () => { it('should create NamespaceMetadataTransaction', (done) => { metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), @@ -194,7 +196,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, key, @@ -218,7 +220,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -243,7 +245,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), diff --git a/test/service/MosaicRestrictionTransactionservice.spec.ts b/test/service/MosaicRestrictionTransactionservice.spec.ts index 7515bfe7a6..c177c9dfbf 100644 --- a/test/service/MosaicRestrictionTransactionservice.spec.ts +++ b/test/service/MosaicRestrictionTransactionservice.spec.ts @@ -37,6 +37,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRestrictionTransactionService'; import { TestingAccount } from '../conf/conf.spec'; import { Page } from '../../src/infrastructure/Page'; +import { Duration } from 'js-joda'; describe('MosaicRestrictionTransactionService', () => { let account: Account; @@ -51,6 +52,7 @@ describe('MosaicRestrictionTransactionService', () => { const globalRestrictionValue = '1000'; const globalRestrictionType = MosaicRestrictionType.LE; const addressRestrictionValue = '10'; + const epochAdjustment = Duration.ofSeconds(1573430400); function mockGlobalRestriction(): Page { const restriction = new MosaicGlobalRestriction( @@ -103,7 +105,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -123,7 +125,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction - with referenceMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -143,7 +145,14 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction', (done) => { mosaicRestrictionTransactionService - .createMosaicAddressRestrictionTransaction(Deadline.create(), NetworkType.MIJIN_TEST, mosaicId, key, account.address, '2000') + .createMosaicAddressRestrictionTransaction( + Deadline.create(epochAdjustment), + NetworkType.MIJIN_TEST, + mosaicId, + key, + account.address, + '2000', + ) .subscribe((transaction: MosaicAddressRestrictionTransaction) => { expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.restrictionKey.toString()).to.be.equal(key.toString()); @@ -156,7 +165,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction with unresolvedMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -176,7 +185,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction with unresolvedAddress', (done) => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -195,7 +204,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedMosaicId', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedAddress, key, @@ -208,7 +217,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedAddress', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -221,7 +230,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid value / key', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -232,7 +241,7 @@ describe('MosaicRestrictionTransactionService', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -245,7 +254,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid address restriction key - MosaicAddressRestriction', () => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicIdWrongKey, invalidKey, diff --git a/test/service/TransactionService.spec.ts b/test/service/TransactionService.spec.ts index 27f210e168..caef819213 100644 --- a/test/service/TransactionService.spec.ts +++ b/test/service/TransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { EMPTY, of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { IListener } from '../../src/infrastructure/IListener'; @@ -44,8 +44,9 @@ import { TransactionService } from '../../src/service/TransactionService'; describe('TransactionService', () => { const generationHash = '82DB2528834C9926F0FCCE042466B24A266F5B685CB66D2869AF6648C043E950'; const account = Account.generateNewAccount(NetworkType.MIJIN_TEST); + const epochAdjustment = Duration.ofSeconds(1573430400); const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -53,21 +54,21 @@ describe('TransactionService', () => { ); const aggregateCompleteTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const aggregateBondedTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(epochAdjustment), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(10000), account.sign(aggregateBondedTransaction, generationHash), @@ -113,7 +114,12 @@ describe('TransactionService', () => { when(transactionRepositoryMock.announce(deepEqual(signedTransaction))).thenReturn(observableOf(transactionAnnounceResponse)); when(listener.confirmed(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create()); + const statusError = new TransactionStatusError( + account.address, + signedTransaction.hash, + 'Some Error', + Deadline.create(epochAdjustment), + ); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository)); @@ -159,7 +165,12 @@ describe('TransactionService', () => { ); when(listener.aggregateBondedAdded(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create()); + const statusError = new TransactionStatusError( + account.address, + signedTransaction.hash, + 'Some Error', + Deadline.create(epochAdjustment), + ); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository));