1515 */
1616import { expect } from 'chai' ;
1717import * as http from 'http' ;
18- import { NetworkRoutesApi , NetworkTypeDTO , NodeInfoDTO , NodeRoutesApi , TransactionFeesDTO } from 'symbol-openapi-typescript-node-client' ;
18+ import { NetworkRoutesApi ,
19+ NetworkTypeDTO ,
20+ NodeInfoDTO ,
21+ NodeRoutesApi ,
22+ TransactionFeesDTO ,
23+ RentalFeesDTO ,
24+ NetworkConfigurationDTO ,
25+ NetworkPropertiesDTO ,
26+ NodeIdentityEqualityStrategy ,
27+ ChainPropertiesDTO ,
28+ PluginsPropertiesDTO ,
29+ AccountLinkNetworkPropertiesDTO ,
30+ AggregateNetworkPropertiesDTO ,
31+ HashLockNetworkPropertiesDTO ,
32+ SecretLockNetworkPropertiesDTO ,
33+ MetadataNetworkPropertiesDTO ,
34+ MosaicNetworkPropertiesDTO ,
35+ MultisigNetworkPropertiesDTO ,
36+ NamespaceNetworkPropertiesDTO ,
37+ AccountRestrictionNetworkPropertiesDTO ,
38+ MosaicRestrictionNetworkPropertiesDTO ,
39+ TransferNetworkPropertiesDTO } from 'symbol-openapi-typescript-node-client' ;
1940import { instance , mock , reset , when } from 'ts-mockito' ;
2041import { DtoMapping } from '../../src/core/utils/DtoMapping' ;
2142import { NetworkHttp } from '../../src/infrastructure/NetworkHttp' ;
2243import { NodeHttp } from '../../src/infrastructure/NodeHttp' ;
2344import { NetworkType } from '../../src/model/network/NetworkType' ;
45+ import { deepEqual } from 'assert' ;
2446
2547describe ( 'NetworkHttp' , ( ) => {
2648 const url = 'http://someHost' ;
@@ -40,7 +62,7 @@ describe('NetworkHttp', () => {
4062 reset ( networkRoutesApi ) ;
4163 } ) ;
4264
43- it ( 'getNetworkFees ' , async ( ) => {
65+ it ( 'getTransactionFees ' , async ( ) => {
4466
4567 const body = new TransactionFeesDTO ( ) ;
4668 body . averageFeeMultiplier = 1 ;
@@ -58,6 +80,22 @@ describe('NetworkHttp', () => {
5880 expect ( networkFees . medianFeeMultiplier ) . to . be . equals ( 4 ) ;
5981 } ) ;
6082
83+ it ( 'getRentalFees' , async ( ) => {
84+
85+ const body = new RentalFeesDTO ( ) ;
86+ body . effectiveChildNamespaceRentalFee = '1' ;
87+ body . effectiveMosaicRentalFee = '2' ;
88+ body . effectiveRootNamespaceRentalFeePerBlock = '3' ;
89+
90+ when ( networkRoutesApi . getRentalFees ( ) ) . thenReturn ( Promise . resolve ( { response, body} ) ) ;
91+
92+ const rentalFees = await networkRepository . getRentalFees ( ) . toPromise ( ) ;
93+ expect ( rentalFees ) . to . be . not . null ;
94+ expect ( rentalFees . effectiveChildNamespaceRentalFee ) . to . be . equals ( '1' ) ;
95+ expect ( rentalFees . effectiveMosaicRentalFee ) . to . be . equals ( '2' ) ;
96+ expect ( rentalFees . effectiveRootNamespaceRentalFeePerBlock ) . to . be . equals ( '3' ) ;
97+ } ) ;
98+
6199 it ( 'getNetworkType' , async ( ) => {
62100
63101 const body = new NodeInfoDTO ( ) ;
@@ -82,4 +120,106 @@ describe('NetworkHttp', () => {
82120 expect ( networkName . name ) . to . be . equals ( body . name ) ;
83121 } ) ;
84122
123+ it ( 'getNetworkProperties' , async ( ) => {
124+
125+ const body = new NetworkConfigurationDTO ( ) ;
126+
127+ const network = new NetworkPropertiesDTO ( ) ;
128+ network . identifier = 'id' ;
129+ network . nodeEqualityStrategy = NodeIdentityEqualityStrategy . Host ;
130+ network . publicKey = 'pubKey' ;
131+ network . generationHash = 'genHash' ;
132+ network . epochAdjustment = '123456' ;
133+
134+ const chain = new ChainPropertiesDTO ( ) ;
135+ chain . blockGenerationTargetTime = '1' ;
136+ chain . blockPruneInterval = '1' ;
137+ chain . blockTimeSmoothingFactor = '1' ;
138+ chain . currencyMosaicId = '1111111111111111' ;
139+ chain . defaultDynamicFeeMultiplier = '1' ;
140+ chain . enableVerifiableReceipts = true ;
141+ chain . enableVerifiableState = true ;
142+ chain . harvestBeneficiaryPercentage = '1' ;
143+ chain . harvestingMosaicId = '2222222222222222' ;
144+ chain . importanceActivityPercentage = '1' ;
145+ chain . importanceGrouping = '1' ;
146+ chain . initialCurrencyAtomicUnits = '1' ;
147+ chain . maxBlockFutureTime = '1' ;
148+ chain . maxDifficultyBlocks = '1' ;
149+ chain . maxHarvesterBalance = '1' ;
150+ chain . maxMosaicAtomicUnits = '1' ;
151+ chain . maxRollbackBlocks = '1' ;
152+ chain . maxTransactionLifetime = '1' ;
153+ chain . maxTransactionsPerBlock = '1' ;
154+ chain . minHarvesterBalance = '1' ;
155+ chain . totalChainImportance = '1' ;
156+
157+ const plugin = new PluginsPropertiesDTO ( ) ;
158+ plugin . accountlink = new AccountLinkNetworkPropertiesDTO ( ) ;
159+ plugin . accountlink . dummy = 'dummy' ;
160+
161+ plugin . aggregate = new AggregateNetworkPropertiesDTO ( ) ;
162+ plugin . aggregate . enableBondedAggregateSupport = true ;
163+ plugin . aggregate . enableStrictCosignatureCheck = true ;
164+ plugin . aggregate . maxBondedTransactionLifetime = '1' ;
165+ plugin . aggregate . maxCosignaturesPerAggregate = '1' ;
166+ plugin . aggregate . maxTransactionsPerAggregate = '1' ;
167+
168+ plugin . lockhash = new HashLockNetworkPropertiesDTO ( ) ;
169+ plugin . lockhash . lockedFundsPerAggregate = '1' ;
170+ plugin . lockhash . maxHashLockDuration = '1' ;
171+
172+ plugin . locksecret = new SecretLockNetworkPropertiesDTO ( ) ;
173+ plugin . locksecret . maxProofSize = '1' ;
174+ plugin . locksecret . maxSecretLockDuration = '1' ;
175+ plugin . locksecret . minProofSize = '1' ;
176+
177+ plugin . metadata = new MetadataNetworkPropertiesDTO ( ) ;
178+ plugin . metadata . maxValueSize = '1' ;
179+
180+ plugin . mosaic = new MosaicNetworkPropertiesDTO ( ) ;
181+ plugin . mosaic . maxMosaicDivisibility = '1' ;
182+ plugin . mosaic . maxMosaicDuration = '1' ;
183+ plugin . mosaic . maxMosaicsPerAccount = '1' ;
184+ plugin . mosaic . mosaicRentalFee = '1' ;
185+ plugin . mosaic . mosaicRentalFeeSinkPublicKey = '1' ;
186+
187+ plugin . multisig = new MultisigNetworkPropertiesDTO ( ) ;
188+ plugin . multisig . maxCosignatoriesPerAccount = '1' ;
189+ plugin . multisig . maxCosignedAccountsPerAccount = '1' ;
190+ plugin . multisig . maxMultisigDepth = '1' ;
191+
192+ plugin . namespace = new NamespaceNetworkPropertiesDTO ( ) ;
193+ plugin . namespace . childNamespaceRentalFee = '1' ;
194+ plugin . namespace . maxChildNamespaces = '1' ;
195+ plugin . namespace . maxNameSize = '1' ;
196+ plugin . namespace . maxNamespaceDepth = '1' ;
197+ plugin . namespace . maxNamespaceDuration = '1' ;
198+ plugin . namespace . minNamespaceDuration = '1' ;
199+ plugin . namespace . namespaceGracePeriodDuration = '1' ;
200+ plugin . namespace . namespaceRentalFeeSinkPublicKey = '1' ;
201+ plugin . namespace . reservedRootNamespaceNames = '1' ;
202+ plugin . namespace . rootNamespaceRentalFeePerBlock = '1' ;
203+
204+ plugin . restrictionaccount = new AccountRestrictionNetworkPropertiesDTO ( ) ;
205+ plugin . restrictionaccount . maxAccountRestrictionValues = '1' ;
206+
207+ plugin . restrictionmosaic = new MosaicRestrictionNetworkPropertiesDTO ( ) ;
208+ plugin . restrictionmosaic . maxMosaicRestrictionValues = '1' ;
209+
210+ plugin . transfer = new TransferNetworkPropertiesDTO ( ) ;
211+ plugin . transfer . maxMessageSize = '1' ;
212+
213+ body . chain = chain ;
214+ body . network = network ;
215+ body . plugins = plugin ;
216+
217+ when ( networkRoutesApi . getNetworkProperties ( ) ) . thenReturn ( Promise . resolve ( { response, body} ) ) ;
218+
219+ const networkProperties = await networkRepository . getNetworkProperties ( ) . toPromise ( ) ;
220+ deepEqual ( networkProperties . network , body . network ) ;
221+ deepEqual ( networkProperties . chain , body . chain ) ;
222+ deepEqual ( networkProperties . plugins , body . plugins ) ;
223+ } ) ;
224+
85225} ) ;
0 commit comments