Skip to content

Commit c8f7c88

Browse files
committed
- Fixed parser bug
- Use rest json payload for unit testing
1 parent 90aa403 commit c8f7c88

File tree

3 files changed

+95
-97
lines changed

3 files changed

+95
-97
lines changed

src/infrastructure/NetworkHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
131131
new ChainProperties(dto.chain.enableVerifiableState, dto.chain.enableVerifiableReceipts,
132132
dto.chain.currencyMosaicId, dto.chain.harvestingMosaicId, dto.chain.blockGenerationTargetTime,
133133
dto.chain.blockTimeSmoothingFactor, dto.chain.importanceGrouping, dto.chain.importanceActivityPercentage,
134-
dto.chain.maxDifficultyBlocks, dto.chain.maxDifficultyBlocks, dto.chain.defaultDynamicFeeMultiplier,
134+
dto.chain.maxRollbackBlocks, dto.chain.maxDifficultyBlocks, dto.chain.defaultDynamicFeeMultiplier,
135135
dto.chain.maxTransactionLifetime, dto.chain.maxBlockFutureTime, dto.chain.initialCurrencyAtomicUnits,
136136
dto.chain.maxMosaicAtomicUnits, dto.chain.totalChainImportance, dto.chain.minHarvesterBalance,
137137
dto.chain.maxHarvesterBalance, dto.chain.harvestBeneficiaryPercentage, dto.chain.blockPruneInterval,
@@ -142,7 +142,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
142142
dto.plugins.aggregate?.maxCosignaturesPerAggregate, dto.plugins.aggregate?.enableStrictCosignatureCheck,
143143
dto.plugins.aggregate?.enableBondedAggregateSupport, dto.plugins.aggregate?.maxBondedTransactionLifetime),
144144
new HashLockNetworkProperties(dto.plugins.lockhash?.lockedFundsPerAggregate, dto.plugins.lockhash?.maxHashLockDuration),
145-
new SecretLockNetworkProperties(dto.plugins.locksecret?.maxSecretLockDuration, dto.plugins.locksecret?.maxProofSize,
145+
new SecretLockNetworkProperties(dto.plugins.locksecret?.maxSecretLockDuration, dto.plugins.locksecret?.minProofSize,
146146
dto.plugins.locksecret?.maxProofSize),
147147
new MetadataNetworkProperties(dto.plugins.metadata?.maxValueSize),
148148
new MosaicNetworkProperties(dto.plugins.mosaic?.maxMosaicsPerAccount, dto.plugins.mosaic?.maxMosaicDuration,

test/infrastructure/NetworkHttp.spec.ts

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { NetworkHttp } from '../../src/infrastructure/NetworkHttp';
4343
import { NodeHttp } from '../../src/infrastructure/NodeHttp';
4444
import { NetworkType } from '../../src/model/network/NetworkType';
4545
import { deepEqual } from 'assert';
46+
import * as testResources from '../resource/TestResources';
4647

4748
describe('NetworkHttp', () => {
4849
const url = 'http://someHost';
@@ -121,105 +122,11 @@ describe('NetworkHttp', () => {
121122
});
122123

123124
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-
125+
const body = testResources.getDummyNetworkProperties();
217126
when(networkRoutesApi.getNetworkProperties()).thenReturn(Promise.resolve({response, body}));
218-
219127
const networkProperties = await networkRepository.getNetworkProperties().toPromise();
220128
deepEqual(networkProperties.network, body.network);
221129
deepEqual(networkProperties.chain, body.chain);
222130
deepEqual(networkProperties.plugins, body.plugins);
223131
});
224-
225132
});

test/resource/TestResources.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
export const getDummyNetworkProperties = () => {
2+
return JSON.parse(`{
3+
"network": {
4+
"identifier": "public-test",
5+
"nodeEqualityStrategy": "public-key",
6+
"publicKey": "86E8FDE6F3FE540ADC1B3A78DFA9B9E735736FC520E0D9C9CD4ADD3255CD9605",
7+
"generationHash": "E759C7C56FD20021C8F0CC7FF5F108A2FEBA3312F6EC6D6A702DF87657FEC55C",
8+
"epochAdjustment": "1573430400s"
9+
},
10+
"chain": {
11+
"enableVerifiableState": true,
12+
"enableVerifiableReceipts": true,
13+
"currencyMosaicId": "0x605E'BB80'8E3A'21C6",
14+
"harvestingMosaicId": "0x501C'4C79'2FEB'D419",
15+
"blockGenerationTargetTime": "15s",
16+
"blockTimeSmoothingFactor": "3000",
17+
"importanceGrouping": "1433",
18+
"importanceActivityPercentage": "5",
19+
"maxRollbackBlocks": "398",
20+
"maxDifficultyBlocks": "60",
21+
"defaultDynamicFeeMultiplier": "1'000",
22+
"maxTransactionLifetime": "24h",
23+
"maxBlockFutureTime": "500ms",
24+
"initialCurrencyAtomicUnits": "8'998'999'998'000'000",
25+
"maxMosaicAtomicUnits": "9'000'000'000'000'000",
26+
"totalChainImportance": "15'000'000",
27+
"minHarvesterBalance": "500",
28+
"maxHarvesterBalance": "50'000'000'000'000",
29+
"harvestBeneficiaryPercentage": "10",
30+
"blockPruneInterval": "360",
31+
"maxTransactionsPerBlock": "6'000"
32+
},
33+
"plugins": {
34+
"accountlink": {
35+
"dummy": "to trigger plugin load"
36+
},
37+
"aggregate": {
38+
"maxTransactionsPerAggregate": "1'000",
39+
"maxCosignaturesPerAggregate": "25",
40+
"enableStrictCosignatureCheck": false,
41+
"enableBondedAggregateSupport": true,
42+
"maxBondedTransactionLifetime": "48h"
43+
},
44+
"lockhash": {
45+
"lockedFundsPerAggregate": "10'000'000",
46+
"maxHashLockDuration": "2d"
47+
},
48+
"locksecret": {
49+
"maxSecretLockDuration": "30d",
50+
"minProofSize": "1",
51+
"maxProofSize": "1000"
52+
},
53+
"metadata": {
54+
"maxValueSize": "1024"
55+
},
56+
"mosaic": {
57+
"maxMosaicsPerAccount": "1'000",
58+
"maxMosaicDuration": "3650d",
59+
"maxMosaicDivisibility": "6",
60+
"mosaicRentalFeeSinkPublicKey": "53E140B5947F104CABC2D6FE8BAEDBC30EF9A0609C717D9613DE593EC2A266D3",
61+
"mosaicRentalFee": "500"
62+
},
63+
"multisig": {
64+
"maxMultisigDepth": "3",
65+
"maxCosignatoriesPerAccount": "25",
66+
"maxCosignedAccountsPerAccount": "25"
67+
},
68+
"namespace": {
69+
"maxNameSize": "64",
70+
"maxChildNamespaces": "256",
71+
"maxNamespaceDepth": "3",
72+
"minNamespaceDuration": "1m",
73+
"maxNamespaceDuration": "365d",
74+
"namespaceGracePeriodDuration": "30d",
75+
"reservedRootNamespaceNames": "xem, nem, user, account, org, com, biz, net, edu, mil, gov, info",
76+
"namespaceRentalFeeSinkPublicKey": "3E82E1C1E4A75ADAA3CBA8C101C3CD31D9817A2EB966EB3B511FB2ED45B8E262",
77+
"rootNamespaceRentalFeePerBlock": "1",
78+
"childNamespaceRentalFee": "100"
79+
},
80+
"restrictionaccount": {
81+
"maxAccountRestrictionValues": "512"
82+
},
83+
"restrictionmosaic": {
84+
"maxMosaicRestrictionValues": "20"
85+
},
86+
"transfer": {
87+
"maxMessageSize": "1024"
88+
}
89+
}
90+
}`);
91+
};

0 commit comments

Comments
 (0)