Skip to content

Commit

Permalink
fix: fixed a mapping issue which left the protocolversion at null (#260)
Browse files Browse the repository at this point in the history
* fix: fixed a mapping issue which left the protocolversion at null

* chore: spotless

* chore: added n2c-socket to .env.dockerfile
  • Loading branch information
Kammerlo authored Dec 17, 2024
1 parent 9f7c181 commit 8577887
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class ProtocolParams {
private Integer maxTxSize; //3
private BigInteger keyDeposit; //5
private BigInteger poolDeposit; //6
private ProtocolVersion protocolVersion; //14
private Integer protocolMajorVer;
private Integer protocolMinorVer;

private BigInteger minPoolCost; //16
private BigInteger adaPerUtxoByte; //17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
@Mapper(config = BaseMapper.class)
public interface ProtocolParamsMapper {

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

@Mapping(target = "coinsPerUtxoSize", source = "adaPerUtxoByte")
@Mapping(target = "minFeeCoefficient", source = "minFeeA")
@Mapping(target = "minFeeConstant", source = "minFeeB")
@Mapping(target = "protocol", source = "protocolVersion.major")
@Mapping(target = "protocol", source = "protocolMajorVer")
ProtocolParameters mapToProtocolParameters(ProtocolParams model);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.jupiter.api.Test;

import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams;
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion;
import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper;
import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapperImpl;
import org.cardanofoundation.rosetta.common.model.cardano.crypto.Signatures;
Expand Down Expand Up @@ -73,7 +72,7 @@ void mapToMetadataResponse_protocolParamsNull_test() {
void mapToMetadataResponse_protocolParamsSomeFieldsNull_test() {
ProtocolParams protocolParams = getProtocolParams();
protocolParams.setKeyDeposit(null);
protocolParams.setProtocolVersion(null);
protocolParams.setProtocolMajorVer(0);
ConstructionMetadataResponse actual = constructionMapper.mapToMetadataResponse(
protocolParams, 1L, 100L);

Expand Down Expand Up @@ -123,7 +122,7 @@ private ProtocolParams getProtocolParams() {
.maxTxSize(2)
.keyDeposit(BigInteger.TWO)
.poolDeposit(BigInteger.TEN)
.protocolVersion(new ProtocolVersion())
.protocolMajorVer(0)
.minPoolCost(BigInteger.ONE)
.adaPerUtxoByte(BigInteger.ONE)
.maxValSize(3L)
Expand Down Expand Up @@ -163,8 +162,7 @@ private void assertProtocolParameters(ProtocolParameters actual, ProtocolParams
assertThat(actual.getPoolDeposit())
.isEqualTo(Objects.toString(expected.getPoolDeposit(), null));
assertThat(actual.getProtocol())
.isEqualTo(expected.getProtocolVersion() != null ? expected.getProtocolVersion()
.getMajor() : null);
.isEqualTo(expected.getProtocolMajorVer() != null ? expected.getProtocolMajorVer() : null);
}

private void assertSignature(Signatures actual, Signature expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ private void assertProtocolParameters(ProtocolParams into, ProtocolParamsEntity
assertThat(into.getMinFeeB()).isEqualTo(param.getMinFeeB());
assertThat(into.getMinPoolCost()).isEqualTo(param.getMinPoolCost());
assertThat(into.getPoolDeposit()).isEqualTo(param.getPoolDeposit());
assertThat(into.getProtocolVersion().getMajor()).isEqualTo(param.getProtocolMajorVer());
assertThat(into.getProtocolVersion().getMinor()).isEqualTo(param.getProtocolMinorVer());
assertThat(into.getProtocolMajorVer()).isEqualTo(param.getProtocolMajorVer());
assertThat(into.getMaxValSize()).isEqualTo(param.getMaxValSize());
assertThat(into.getMaxCollateralInputs()).isEqualTo(param.getMaxCollateralInputs());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.cardanofoundation.rosetta.api.BaseMapperSetup;
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams;
import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion;

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

Expand All @@ -32,13 +31,11 @@ void fromDomainObjectToRosettaTest() {
assertEquals(protocolParams.getMinFeeB(), protocolParameters.getMinFeeConstant());
assertEquals(protocolParams.getMinPoolCost().toString(), protocolParameters.getMinPoolCost());
assertEquals(protocolParams.getPoolDeposit().toString(), protocolParameters.getPoolDeposit());
assertEquals(protocolParams.getProtocolVersion().getMajor(), protocolParameters.getProtocol());
assertEquals(protocolParams.getProtocolMajorVer(), protocolParameters.getProtocol());

}

private ProtocolParams newProtocolParams() {
ProtocolVersion protocolVersion = new ProtocolVersion();
protocolVersion.setMajor(10);
return ProtocolParams.builder()
.adaPerUtxoByte(BigInteger.valueOf(1))
.maxTxSize(2)
Expand All @@ -49,7 +46,7 @@ private ProtocolParams newProtocolParams() {
.minFeeB(7)
.minPoolCost(BigInteger.valueOf(8))
.poolDeposit(BigInteger.valueOf(9))
.protocolVersion(protocolVersion)
.protocolMajorVer(10)
.build();

}
Expand Down
2 changes: 0 additions & 2 deletions docker-compose-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ services:
volumes:
- ${CARDANO_NODE_DIR}:/node
cardano-node:
build:
context: ./docker/dockerfiles/node
image: ghcr.io/intersectmbo/cardano-node:${CARDANO_NODE_VERSION}
environment:
- NETWORK=${NETWORK}
Expand Down
8 changes: 7 additions & 1 deletion docker/dockerfiles/mithril/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ FROM ubuntu:22.04 AS cardano-builder

WORKDIR /root/src

RUN apt update --fix-missing \
&& apt install -y --no-install-recommends curl ca-certificates \
&& apt-get clean

# Mithril setup
ARG MITHRIL_VERSION=2445.0
# Install dependencies
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
&& export PATH="$HOME/.cargo/bin:$PATH" \
&& apt update --fix-missing \
&& apt install -y --no-install-recommends \
build-essential m4 libssl-dev docker jq git cargo ca-certificates wget \
build-essential m4 libssl-dev docker jq git \
&& apt-get clean
RUN git clone https://github.com/input-output-hk/mithril.git \
&& export PATH="$HOME/.cargo/bin:$PATH" \
&& cd mithril \
&& git checkout $MITHRIL_VERSION \
&& cd mithril-client-cli \
Expand Down

0 comments on commit 8577887

Please sign in to comment.