1 | package org.cardanofoundation.explorer.api.util; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.List; | |
5 | ||
6 | import org.cardanofoundation.explorer.api.common.enumeration.ProtocolParamGroup; | |
7 | import org.cardanofoundation.explorer.api.model.ProtocolParamUpdate; | |
8 | import org.cardanofoundation.explorer.common.entity.ledgersync.EpochParam; | |
9 | ||
10 | public class ProtocolParamUtil { | |
11 | private ProtocolParamUtil() {} | |
12 | ||
13 | public static List<ProtocolParamGroup> getGroupsWithNonNullField(EpochParam params) { | |
14 | List<ProtocolParamGroup> groups = new ArrayList<>(); | |
15 | // todo: Economic: check monetary expansion (rho), treasury expansion (tau), minimum Lovelace | |
16 | // deposit per byte of serialized UTxO (coinsPerUTxOByte) | |
17 |
1
1. getGroupsWithNonNullField : negated conditional → NO_COVERAGE |
if (isNonNull( |
18 | params.getMinFeeA(), | |
19 | params.getMinFeeB(), | |
20 | params.getKeyDeposit(), | |
21 | params.getPoolDeposit(), | |
22 | params.getMinPoolCost(), | |
23 | params.getPriceMem(), | |
24 | params.getPriceStep())) { | |
25 | groups.add(ProtocolParamGroup.ECONOMIC); | |
26 | } | |
27 | ||
28 |
1
1. getGroupsWithNonNullField : negated conditional → NO_COVERAGE |
if (isNonNull( |
29 | params.getMaxBlockSize(), | |
30 | params.getMaxTxSize(), | |
31 | params.getMaxBhSize(), | |
32 | params.getMaxValSize(), | |
33 | params.getMaxTxExMem(), | |
34 | params.getMaxTxExSteps(), | |
35 | params.getMaxBlockExMem(), | |
36 | params.getMaxBlockExSteps(), | |
37 | params.getMaxCollateralInputs())) { | |
38 | groups.add(ProtocolParamGroup.NETWORK); | |
39 | } | |
40 | // todo: Technical: check pool retirement maximum epoch (eMax), | |
41 | /* pool pledge influence (a0) as OptimalPoolCount, desired number of pools (nOpt) as Influence | |
42 | * Plutus execution cost models (costModels) as CostModel, proportion of collateral needed for scripts (collateralPercentage) as CollateralPercent */ | |
43 |
1
1. getGroupsWithNonNullField : negated conditional → NO_COVERAGE |
if (isNonNull( |
44 | params.getOptimalPoolCount(), | |
45 | params.getInfluence(), | |
46 | params.getCostModel(), | |
47 | params.getCollateralPercent())) { | |
48 | groups.add(ProtocolParamGroup.TECHNICAL); | |
49 | } | |
50 | ||
51 |
1
1. getGroupsWithNonNullField : negated conditional → NO_COVERAGE |
if (isNonNull( |
52 | params.getPvtMotionNoConfidence(), | |
53 | params.getPvtCommitteeNormal(), | |
54 | params.getPvtCommitteeNoConfidence(), | |
55 | params.getPvtHardForkInitiation(), | |
56 | params.getPvtPPSecurityGroup(), | |
57 | params.getDvtMotionNoConfidence(), | |
58 | params.getDvtCommitteeNormal(), | |
59 | params.getDvtCommitteeNoConfidence(), | |
60 | params.getDvtUpdateToConstitution(), | |
61 | params.getDvtHardForkInitiation(), | |
62 | params.getDvtPPNetworkGroup(), | |
63 | params.getDvtPPEconomicGroup(), | |
64 | params.getDvtPPTechnicalGroup(), | |
65 | params.getDvtPPGovGroup(), | |
66 | params.getDvtTreasuryWithdrawal(), | |
67 | params.getCommitteeMinSize(), | |
68 | params.getCommitteeMaxTermLength(), | |
69 | params.getGovActionLifetime(), | |
70 | params.getGovActionDeposit(), | |
71 | params.getDrepDeposit(), | |
72 | params.getDrepActivity())) { | |
73 | groups.add(ProtocolParamGroup.GOVERNANCE); | |
74 | } | |
75 | /// todo: Security: check minimum Lovelace deposit per byte of serialized UTxO | |
76 | // (coinsPerUTxOByte) | |
77 |
1
1. getGroupsWithNonNullField : negated conditional → NO_COVERAGE |
if (isNonNull( |
78 | params.getMaxBlockSize(), | |
79 | params.getMaxTxSize(), | |
80 | params.getMaxBhSize(), | |
81 | params.getMaxValSize(), | |
82 | params.getMaxBlockExMem(), | |
83 | params.getMaxBlockExSteps(), | |
84 | params.getMinFeeA(), | |
85 | params.getMinFeeB(), | |
86 | params.getGovActionDeposit(), | |
87 | params.getMinFeeRefScriptCostPerByte())) { | |
88 | groups.add(ProtocolParamGroup.SECURITY); | |
89 | } | |
90 | ||
91 |
1
1. getGroupsWithNonNullField : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/ProtocolParamUtil::getGroupsWithNonNullField → NO_COVERAGE |
return groups; |
92 | } | |
93 | ||
94 | public static List<ProtocolParamGroup> getGroupsWithNonNullField(ProtocolParamUpdate params) { | |
95 | List<ProtocolParamGroup> groups = new ArrayList<>(); | |
96 | // todo: Economic: check monetary expansion (rho), treasury expansion (tau), minimum Lovelace | |
97 | // deposit per byte of serialized UTxO (coinsPerUTxOByte) | |
98 |
1
1. getGroupsWithNonNullField : negated conditional → SURVIVED |
if (isNonNull( |
99 | params.getMinFeeA(), | |
100 | params.getMinFeeB(), | |
101 | params.getKeyDeposit(), | |
102 | params.getPoolDeposit(), | |
103 | params.getMinPoolCost(), | |
104 | params.getPriceMem(), | |
105 | params.getPriceStep())) { | |
106 | groups.add(ProtocolParamGroup.ECONOMIC); | |
107 | } | |
108 | ||
109 |
1
1. getGroupsWithNonNullField : negated conditional → SURVIVED |
if (isNonNull( |
110 | params.getMaxBlockSize(), | |
111 | params.getMaxTxSize(), | |
112 | params.getMaxBlockHeaderSize(), | |
113 | params.getMaxValSize(), | |
114 | params.getMaxTxExMem(), | |
115 | params.getMaxTxExSteps(), | |
116 | params.getMaxBlockExMem(), | |
117 | params.getMaxBlockExSteps(), | |
118 | params.getMaxCollateralInputs())) { | |
119 | groups.add(ProtocolParamGroup.NETWORK); | |
120 | } | |
121 | // todo: Technical: check pool retirement maximum epoch (eMax), | |
122 | /* pool pledge influence (a0) as OptimalPoolCount, desired number of pools (nOpt) as Influence | |
123 | * Plutus execution cost models (costModels) as CostModel, proportion of collateral needed for scripts (collateralPercentage) as CollateralPercent */ | |
124 |
1
1. getGroupsWithNonNullField : negated conditional → SURVIVED |
if (isNonNull( |
125 | params.getNopt(), | |
126 | params.getPoolPledgeInfluence(), | |
127 | params.getCostModels(), | |
128 | params.getCollateralPercent())) { | |
129 | groups.add(ProtocolParamGroup.TECHNICAL); | |
130 | } | |
131 | ||
132 |
1
1. getGroupsWithNonNullField : negated conditional → KILLED |
if (isNonNull( |
133 | params.getDrepVotingThresholds(), | |
134 | params.getPoolVotingThresholds(), | |
135 | params.getGovActionLifetime(), | |
136 | params.getGovActionDeposit(), | |
137 | params.getDrepDeposit(), | |
138 | params.getDrepActivity(), | |
139 | params.getCommitteeMinSize(), | |
140 | params.getCommitteeMaxTermLength())) { | |
141 | groups.add(ProtocolParamGroup.GOVERNANCE); | |
142 | } | |
143 | /// todo: Security: check minimum Lovelace deposit per byte of serialized UTxO | |
144 | // (coinsPerUTxOByte) | |
145 |
1
1. getGroupsWithNonNullField : negated conditional → SURVIVED |
if (isNonNull( |
146 | params.getMaxBlockSize(), | |
147 | params.getMaxTxSize(), | |
148 | params.getMaxBlockHeaderSize(), | |
149 | params.getMaxValSize(), | |
150 | params.getMaxBlockExMem(), | |
151 | params.getMaxBlockExSteps(), | |
152 | params.getMinFeeA(), | |
153 | params.getMinFeeB(), | |
154 | params.getGovActionDeposit(), | |
155 | params.getMinFeeRefScriptCostPerByte())) { | |
156 | groups.add(ProtocolParamGroup.SECURITY); | |
157 | } | |
158 | ||
159 |
1
1. getGroupsWithNonNullField : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/ProtocolParamUtil::getGroupsWithNonNullField → KILLED |
return groups; |
160 | } | |
161 | ||
162 | private static boolean isNonNull(Object... objects) { | |
163 | for (Object obj : objects) { | |
164 |
1
1. isNonNull : negated conditional → SURVIVED |
if (obj != null) { |
165 |
1
1. isNonNull : replaced boolean return with false for org/cardanofoundation/explorer/api/util/ProtocolParamUtil::isNonNull → KILLED |
return true; |
166 | } | |
167 | } | |
168 |
1
1. isNonNull : replaced boolean return with true for org/cardanofoundation/explorer/api/util/ProtocolParamUtil::isNonNull → NO_COVERAGE |
return false; |
169 | } | |
170 | } | |
Mutations | ||
17 |
1.1 |
|
28 |
1.1 |
|
43 |
1.1 |
|
51 |
1.1 |
|
77 |
1.1 |
|
91 |
1.1 |
|
98 |
1.1 |
|
109 |
1.1 |
|
124 |
1.1 |
|
132 |
1.1 |
|
145 |
1.1 |
|
159 |
1.1 |
|
164 |
1.1 |
|
165 |
1.1 |
|
168 |
1.1 |