@@ -36,7 +36,7 @@ import { AccountRestrictionModificationAction } from '../../src/model/restrictio
3636import { AccountRestrictionFlags } from '../../src/model/restriction/AccountRestrictionType' ;
3737import { MosaicRestrictionType } from '../../src/model/restriction/MosaicRestrictionType' ;
3838import { AccountAddressRestrictionTransaction } from '../../src/model/transaction/AccountAddressRestrictionTransaction' ;
39- import { AccountLinkTransaction } from '../../src/model/transaction/AccountLinkTransaction ' ;
39+ import { AccountKeyLinkTransaction } from '../../src/model/transaction/AccountKeyLinkTransaction ' ;
4040import { AccountMetadataTransaction } from '../../src/model/transaction/AccountMetadataTransaction' ;
4141import { AccountMosaicRestrictionTransaction } from '../../src/model/transaction/AccountMosaicRestrictionTransaction' ;
4242import { AccountOperationRestrictionTransaction } from '../../src/model/transaction/AccountOperationRestrictionTransaction' ;
@@ -66,6 +66,9 @@ import { TransferTransaction } from '../../src/model/transaction/TransferTransac
6666import { UInt64 } from '../../src/model/UInt64' ;
6767import { IntegrationTestHelper } from './IntegrationTestHelper' ;
6868import { LockHashUtils } from '../../src/core/utils/LockHashUtils' ;
69+ import { VrfKeyLinkTransaction } from '../../src/model/transaction/VrfKeyLinkTransaction' ;
70+ import { VotingKeyLinkTransaction } from '../../src/model/transaction/VotingKeyLinkTransaction' ;
71+ import { NodeKeyLinkTransaction } from '../../src/model/transaction/NodeKeyLinkTransaction' ;
6972
7073// eslint-disable-next-line @typescript-eslint/no-var-requires
7174const CryptoJS = require ( 'crypto-js' ) ;
@@ -89,6 +92,7 @@ describe('TransactionHttp', () => {
8992 let namespaceId : NamespaceId ;
9093 let harvestingAccount : Account ;
9194 let transactionRepository : TransactionRepository ;
95+ let votingKey : string ;
9296 // eslint-disable-next-line @typescript-eslint/no-var-requires
9397 const secureRandom = require ( 'secure-random' ) ;
9498 // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -106,6 +110,7 @@ describe('TransactionHttp', () => {
106110 harvestingAccount = helper . harvestingAccount ;
107111 generationHash = helper . generationHash ;
108112 networkType = helper . networkType ;
113+ votingKey = Convert . uint8ToHex ( Crypto . randomBytes ( 48 ) ) ;
109114 accountRepository = helper . repositoryFactory . createAccountRepository ( ) ;
110115 namespaceRepository = helper . repositoryFactory . createNamespaceRepository ( ) ;
111116 transactionRepository = helper . repositoryFactory . createTransactionRepository ( ) ;
@@ -370,6 +375,7 @@ describe('TransactionHttp', () => {
370375 account3 . address ,
371376 UInt64 . fromUint ( 2 ) ,
372377 networkType ,
378+ undefined ,
373379 helper . maxFee ,
374380 ) ;
375381 const aggregateTransaction = AggregateTransaction . createComplete (
@@ -535,12 +541,14 @@ describe('TransactionHttp', () => {
535541 return helper . announce ( signedTransaction ) ;
536542 } ) ;
537543 } ) ;
538- describe ( 'AccountRestrictionTransaction - Incoming Operation' , ( ) => {
544+
545+ describe ( 'AccountRestrictionTransaction - Outgoing Operation' , ( ) => {
539546 it ( 'standalone' , ( ) => {
547+ AccountRestrictionModification . createForOperation ( AccountRestrictionModificationAction . Add , TransactionType . ACCOUNT_KEY_LINK ) ;
540548 const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
541549 Deadline . create ( ) ,
542- AccountRestrictionFlags . BlockIncomingTransactionType ,
543- [ TransactionType . ACCOUNT_LINK ] ,
550+ AccountRestrictionFlags . BlockOutgoingTransactionType ,
551+ [ TransactionType . ACCOUNT_KEY_LINK ] ,
544552 [ ] ,
545553 networkType ,
546554 helper . maxFee ,
@@ -554,13 +562,13 @@ describe('TransactionHttp', () => {
554562 } ) ;
555563 } ) ;
556564 } ) ;
557- describe ( 'AccountRestrictionTransaction - Incoming Operation' , ( ) => {
565+ describe ( 'AccountRestrictionTransaction - Outgoing Operation' , ( ) => {
558566 it ( 'aggregate' , ( ) => {
559567 const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
560568 Deadline . create ( ) ,
561- AccountRestrictionFlags . BlockIncomingTransactionType ,
569+ AccountRestrictionFlags . BlockOutgoingTransactionType ,
562570 [ ] ,
563- [ TransactionType . ACCOUNT_LINK ] ,
571+ [ TransactionType . ACCOUNT_KEY_LINK ] ,
564572 networkType ,
565573 helper . maxFee ,
566574 ) ;
@@ -576,69 +584,105 @@ describe('TransactionHttp', () => {
576584 } ) ;
577585 } ) ;
578586
579- describe ( 'AccountRestrictionTransaction - Outgoing Operation ' , ( ) => {
587+ describe ( 'AccountKeyLinkTransaction ' , ( ) => {
580588 it ( 'standalone' , ( ) => {
581- AccountRestrictionModification . createForOperation ( AccountRestrictionModificationAction . Add , TransactionType . ACCOUNT_LINK ) ;
582- const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
589+ const accountLinkTransaction = AccountKeyLinkTransaction . create (
583590 Deadline . create ( ) ,
584- AccountRestrictionFlags . BlockOutgoingTransactionType ,
585- [ TransactionType . ACCOUNT_LINK ] ,
586- [ ] ,
591+ account3 . publicKey ,
592+ LinkAction . Link ,
587593 networkType ,
588594 helper . maxFee ,
589595 ) ;
590- const signedTransaction = addressModification . signWith ( account3 , generationHash ) ;
596+ const signedTransaction = accountLinkTransaction . signWith ( account , generationHash ) ;
591597
592- return helper . announce ( signedTransaction ) . then ( ( transaction : AccountOperationRestrictionTransaction ) => {
593- expect ( transaction . restrictionAdditions , 'RestrictionAdditions ' ) . not . to . be . undefined ;
594- expect ( transaction . restrictionDeletions , 'RestrictionDeletions ' ) . not . to . be . undefined ;
595- expect ( transaction . restrictionFlags , 'RestrictionFlags' ) . not . to . be . undefined ;
598+ return helper . announce ( signedTransaction ) . then ( ( transaction : AccountKeyLinkTransaction ) => {
599+ expect ( transaction . remotePublicKey , 'RemotePublicKey ' ) . not . to . be . undefined ;
600+ expect ( transaction . linkAction , 'LinkAction ' ) . not . to . be . undefined ;
601+ return signedTransaction ;
596602 } ) ;
597603 } ) ;
598604 } ) ;
599- describe ( 'AccountRestrictionTransaction - Outgoing Operation ' , ( ) => {
605+ describe ( 'AccountKeyLinkTransaction ' , ( ) => {
600606 it ( 'aggregate' , ( ) => {
601- const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
607+ const accountLinkTransaction = AccountKeyLinkTransaction . create (
602608 Deadline . create ( ) ,
603- AccountRestrictionFlags . BlockOutgoingTransactionType ,
609+ account3 . publicKey ,
610+ LinkAction . Unlink ,
611+ networkType ,
612+ helper . maxFee ,
613+ ) ;
614+ const aggregateTransaction = AggregateTransaction . createComplete (
615+ Deadline . create ( ) ,
616+ [ accountLinkTransaction . toAggregate ( account . publicAccount ) ] ,
617+ networkType ,
604618 [ ] ,
605- [ TransactionType . ACCOUNT_LINK ] ,
619+ helper . maxFee ,
620+ ) ;
621+ const signedTransaction = aggregateTransaction . signWith ( account , generationHash ) ;
622+ return helper . announce ( signedTransaction ) ;
623+ } ) ;
624+ } ) ;
625+
626+ describe ( 'VrfKeyLinkTransaction' , ( ) => {
627+ it ( 'standalone' , ( ) => {
628+ const vrfKeyLinkTransaction = VrfKeyLinkTransaction . create (
629+ Deadline . create ( ) ,
630+ harvestingAccount . publicKey ,
631+ LinkAction . Link ,
632+ networkType ,
633+ helper . maxFee ,
634+ ) ;
635+ const signedTransaction = vrfKeyLinkTransaction . signWith ( account , generationHash ) ;
636+
637+ return helper . announce ( signedTransaction ) . then ( ( transaction : VrfKeyLinkTransaction ) => {
638+ expect ( transaction . linkedPublicKey , 'LinkedPublicKey' ) . not . to . be . undefined ;
639+ expect ( transaction . linkAction , 'LinkAction' ) . not . to . be . undefined ;
640+ return signedTransaction ;
641+ } ) ;
642+ } ) ;
643+ } ) ;
644+ describe ( 'VrfKeyLinkTransaction' , ( ) => {
645+ it ( 'aggregate' , ( ) => {
646+ const vrfKeyLinkTransaction = VrfKeyLinkTransaction . create (
647+ Deadline . create ( ) ,
648+ harvestingAccount . publicKey ,
649+ LinkAction . Unlink ,
606650 networkType ,
607651 helper . maxFee ,
608652 ) ;
609653 const aggregateTransaction = AggregateTransaction . createComplete (
610654 Deadline . create ( ) ,
611- [ addressModification . toAggregate ( account3 . publicAccount ) ] ,
655+ [ vrfKeyLinkTransaction . toAggregate ( account . publicAccount ) ] ,
612656 networkType ,
613657 [ ] ,
614658 helper . maxFee ,
615659 ) ;
616- const signedTransaction = aggregateTransaction . signWith ( account3 , generationHash ) ;
660+ const signedTransaction = aggregateTransaction . signWith ( account , generationHash ) ;
617661 return helper . announce ( signedTransaction ) ;
618662 } ) ;
619663 } ) ;
620664
621- describe ( 'AccountLinkTransaction ' , ( ) => {
665+ describe ( 'NodeKeyLinkTransaction ' , ( ) => {
622666 it ( 'standalone' , ( ) => {
623- const accountLinkTransaction = AccountLinkTransaction . create (
667+ const nodeKeyLinkTransaction = NodeKeyLinkTransaction . create (
624668 Deadline . create ( ) ,
625669 harvestingAccount . publicKey ,
626670 LinkAction . Link ,
627671 networkType ,
628672 helper . maxFee ,
629673 ) ;
630- const signedTransaction = accountLinkTransaction . signWith ( account , generationHash ) ;
674+ const signedTransaction = nodeKeyLinkTransaction . signWith ( account , generationHash ) ;
631675
632- return helper . announce ( signedTransaction ) . then ( ( transaction : AccountLinkTransaction ) => {
633- expect ( transaction . remotePublicKey , 'RemotePublicKey ' ) . not . to . be . undefined ;
676+ return helper . announce ( signedTransaction ) . then ( ( transaction : NodeKeyLinkTransaction ) => {
677+ expect ( transaction . linkedPublicKey , 'LinkedPublicKey ' ) . not . to . be . undefined ;
634678 expect ( transaction . linkAction , 'LinkAction' ) . not . to . be . undefined ;
635679 return signedTransaction ;
636680 } ) ;
637681 } ) ;
638682 } ) ;
639- describe ( 'AccountLinkTransaction ' , ( ) => {
683+ describe ( 'NodeKeyLinkTransaction ' , ( ) => {
640684 it ( 'aggregate' , ( ) => {
641- const accountLinkTransaction = AccountLinkTransaction . create (
685+ const nodeKeyLinkTransaction = NodeKeyLinkTransaction . create (
642686 Deadline . create ( ) ,
643687 harvestingAccount . publicKey ,
644688 LinkAction . Unlink ,
@@ -647,7 +691,46 @@ describe('TransactionHttp', () => {
647691 ) ;
648692 const aggregateTransaction = AggregateTransaction . createComplete (
649693 Deadline . create ( ) ,
650- [ accountLinkTransaction . toAggregate ( account . publicAccount ) ] ,
694+ [ nodeKeyLinkTransaction . toAggregate ( account . publicAccount ) ] ,
695+ networkType ,
696+ [ ] ,
697+ helper . maxFee ,
698+ ) ;
699+ const signedTransaction = aggregateTransaction . signWith ( account , generationHash ) ;
700+ return helper . announce ( signedTransaction ) ;
701+ } ) ;
702+ } ) ;
703+
704+ describe ( 'VotingKeyLinkTransaction' , ( ) => {
705+ it ( 'standalone' , ( ) => {
706+ const votingLinkTransaction = VotingKeyLinkTransaction . create (
707+ Deadline . create ( ) ,
708+ votingKey ,
709+ LinkAction . Link ,
710+ networkType ,
711+ helper . maxFee ,
712+ ) ;
713+ const signedTransaction = votingLinkTransaction . signWith ( account , generationHash ) ;
714+
715+ return helper . announce ( signedTransaction ) . then ( ( transaction : VotingKeyLinkTransaction ) => {
716+ expect ( transaction . linkedPublicKey , 'LinkedPublicKey' ) . not . to . be . undefined ;
717+ expect ( transaction . linkAction , 'LinkAction' ) . not . to . be . undefined ;
718+ return signedTransaction ;
719+ } ) ;
720+ } ) ;
721+ } ) ;
722+ describe ( 'VotingKeyLinkTransaction' , ( ) => {
723+ it ( 'aggregate' , ( ) => {
724+ const votingLinkTransaction = VotingKeyLinkTransaction . create (
725+ Deadline . create ( ) ,
726+ votingKey ,
727+ LinkAction . Unlink ,
728+ networkType ,
729+ helper . maxFee ,
730+ ) ;
731+ const aggregateTransaction = AggregateTransaction . createComplete (
732+ Deadline . create ( ) ,
733+ [ votingLinkTransaction . toAggregate ( account . publicAccount ) ] ,
651734 networkType ,
652735 [ ] ,
653736 helper . maxFee ,
@@ -1378,7 +1461,7 @@ describe('TransactionHttp', () => {
13781461 it ( 'should return effective paid fee given transactionHash' , async ( ) => {
13791462 const effectiveFee = await transactionRepository . getTransactionEffectiveFee ( transactionHash ) . toPromise ( ) ;
13801463 expect ( effectiveFee ) . to . not . be . undefined ;
1381- expect ( effectiveFee ) . to . be . equal ( 0 ) ;
1464+ expect ( effectiveFee ) . not . to . be . equal ( 0 ) ;
13821465 } ) ;
13831466 } ) ;
13841467} ) ;
0 commit comments