Skip to content

Commit 8577887

Browse files
authored
fix: fixed a mapping issue which left the protocolversion at null (#260)
* fix: fixed a mapping issue which left the protocolversion at null * chore: spotless * chore: added n2c-socket to .env.dockerfile
1 parent 9f7c181 commit 8577887

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/ProtocolParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public class ProtocolParams {
2727
private Integer maxTxSize; //3
2828
private BigInteger keyDeposit; //5
2929
private BigInteger poolDeposit; //6
30-
private ProtocolVersion protocolVersion; //14
30+
private Integer protocolMajorVer;
31+
private Integer protocolMinorVer;
3132

3233
private BigInteger minPoolCost; //16
3334
private BigInteger adaPerUtxoByte; //17

api/src/main/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
@Mapper(config = BaseMapper.class)
1212
public interface ProtocolParamsMapper {
1313

14-
@Mapping(target = "protocolVersion.major", source = "protocolMajorVer")
15-
@Mapping(target = "protocolVersion.minor", source = "protocolMinorVer")
1614
ProtocolParams mapProtocolParamsToEntity(ProtocolParamsEntity entity);
1715

1816
@Mapping(target = "coinsPerUtxoSize", source = "adaPerUtxoByte")
1917
@Mapping(target = "minFeeCoefficient", source = "minFeeA")
2018
@Mapping(target = "minFeeConstant", source = "minFeeB")
21-
@Mapping(target = "protocol", source = "protocolVersion.major")
19+
@Mapping(target = "protocol", source = "protocolMajorVer")
2220
ProtocolParameters mapToProtocolParameters(ProtocolParams model);
2321
}

api/src/test/java/org/cardanofoundation/rosetta/api/construction/mapper/ConstructionMapperTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.junit.jupiter.api.Test;
1818

1919
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams;
20-
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion;
2120
import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper;
2221
import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapperImpl;
2322
import org.cardanofoundation.rosetta.common.model.cardano.crypto.Signatures;
@@ -73,7 +72,7 @@ void mapToMetadataResponse_protocolParamsNull_test() {
7372
void mapToMetadataResponse_protocolParamsSomeFieldsNull_test() {
7473
ProtocolParams protocolParams = getProtocolParams();
7574
protocolParams.setKeyDeposit(null);
76-
protocolParams.setProtocolVersion(null);
75+
protocolParams.setProtocolMajorVer(0);
7776
ConstructionMetadataResponse actual = constructionMapper.mapToMetadataResponse(
7877
protocolParams, 1L, 100L);
7978

@@ -123,7 +122,7 @@ private ProtocolParams getProtocolParams() {
123122
.maxTxSize(2)
124123
.keyDeposit(BigInteger.TWO)
125124
.poolDeposit(BigInteger.TEN)
126-
.protocolVersion(new ProtocolVersion())
125+
.protocolMajorVer(0)
127126
.minPoolCost(BigInteger.ONE)
128127
.adaPerUtxoByte(BigInteger.ONE)
129128
.maxValSize(3L)
@@ -163,8 +162,7 @@ private void assertProtocolParameters(ProtocolParameters actual, ProtocolParams
163162
assertThat(actual.getPoolDeposit())
164163
.isEqualTo(Objects.toString(expected.getPoolDeposit(), null));
165164
assertThat(actual.getProtocol())
166-
.isEqualTo(expected.getProtocolVersion() != null ? expected.getProtocolVersion()
167-
.getMajor() : null);
165+
.isEqualTo(expected.getProtocolMajorVer() != null ? expected.getProtocolMajorVer() : null);
168166
}
169167

170168
private void assertSignature(Signatures actual, Signature expected) {

api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapperTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ private void assertProtocolParameters(ProtocolParams into, ProtocolParamsEntity
6262
assertThat(into.getMinFeeB()).isEqualTo(param.getMinFeeB());
6363
assertThat(into.getMinPoolCost()).isEqualTo(param.getMinPoolCost());
6464
assertThat(into.getPoolDeposit()).isEqualTo(param.getPoolDeposit());
65-
assertThat(into.getProtocolVersion().getMajor()).isEqualTo(param.getProtocolMajorVer());
66-
assertThat(into.getProtocolVersion().getMinor()).isEqualTo(param.getProtocolMinorVer());
65+
assertThat(into.getProtocolMajorVer()).isEqualTo(param.getProtocolMajorVer());
6766
assertThat(into.getMaxValSize()).isEqualTo(param.getMaxValSize());
6867
assertThat(into.getMaxCollateralInputs()).isEqualTo(param.getMaxCollateralInputs());
6968
}

api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsToRosettaProtocolParamsTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import org.cardanofoundation.rosetta.api.BaseMapperSetup;
1111
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams;
12-
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion;
1312

1413
import static org.junit.jupiter.api.Assertions.assertEquals;
1514

@@ -32,13 +31,11 @@ void fromDomainObjectToRosettaTest() {
3231
assertEquals(protocolParams.getMinFeeB(), protocolParameters.getMinFeeConstant());
3332
assertEquals(protocolParams.getMinPoolCost().toString(), protocolParameters.getMinPoolCost());
3433
assertEquals(protocolParams.getPoolDeposit().toString(), protocolParameters.getPoolDeposit());
35-
assertEquals(protocolParams.getProtocolVersion().getMajor(), protocolParameters.getProtocol());
34+
assertEquals(protocolParams.getProtocolMajorVer(), protocolParameters.getProtocol());
3635

3736
}
3837

3938
private ProtocolParams newProtocolParams() {
40-
ProtocolVersion protocolVersion = new ProtocolVersion();
41-
protocolVersion.setMajor(10);
4239
return ProtocolParams.builder()
4340
.adaPerUtxoByte(BigInteger.valueOf(1))
4441
.maxTxSize(2)
@@ -49,7 +46,7 @@ private ProtocolParams newProtocolParams() {
4946
.minFeeB(7)
5047
.minPoolCost(BigInteger.valueOf(8))
5148
.poolDeposit(BigInteger.valueOf(9))
52-
.protocolVersion(protocolVersion)
49+
.protocolMajorVer(10)
5350
.build();
5451

5552
}

docker-compose-node.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ services:
1212
volumes:
1313
- ${CARDANO_NODE_DIR}:/node
1414
cardano-node:
15-
build:
16-
context: ./docker/dockerfiles/node
1715
image: ghcr.io/intersectmbo/cardano-node:${CARDANO_NODE_VERSION}
1816
environment:
1917
- NETWORK=${NETWORK}

docker/dockerfiles/mithril/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ FROM ubuntu:22.04 AS cardano-builder
22

33
WORKDIR /root/src
44

5+
RUN apt update --fix-missing \
6+
&& apt install -y --no-install-recommends curl ca-certificates \
7+
&& apt-get clean
8+
59
# Mithril setup
610
ARG MITHRIL_VERSION=2445.0
711
# Install dependencies
812
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
13+
&& export PATH="$HOME/.cargo/bin:$PATH" \
914
&& apt update --fix-missing \
1015
&& apt install -y --no-install-recommends \
11-
build-essential m4 libssl-dev docker jq git cargo ca-certificates wget \
16+
build-essential m4 libssl-dev docker jq git \
1217
&& apt-get clean
1318
RUN git clone https://github.com/input-output-hk/mithril.git \
19+
&& export PATH="$HOME/.cargo/bin:$PATH" \
1420
&& cd mithril \
1521
&& git checkout $MITHRIL_VERSION \
1622
&& cd mithril-client-cli \

0 commit comments

Comments
 (0)