diff --git a/CHANGELOG.md b/CHANGELOG.md index 58359c11..ec3ad3b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,34 @@ All notable changes to this project will be documented in this file. +## [[8.3.1]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.3.1) 2023-12-20 + +### Bug Fixes + +- Remove deprecated `OrderSigner` class and `OrderTag` enum. (#430) +- Remove deprecated `com.iexec.common.chain.eip712.entity` package. (#431) +- Remove deprecated `com.iexec.common.chain.eip712` package. (#432) +- Remove deprecated `com.iexec.common.sdk.order.payload` package. (#433) + +### Dependency Upgrades + +- Upgrade to Spring Boot 2.7.17. (#435) +- Upgrade to `jenkins-library` 2.7.4. (#434) +- Upgrade to `iexec-commons-poco` 3.2.0. (#436) + ## [[8.3.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.3.0) 2023-09-26 ### New Features + - Add new `POST_COMPUTE_TOO_LONG_RESULT_FILE_NAME` replicate status cause. (#422) + ### Quality + - Upgrade to Gradle 8.2.1 with up-to-date plugins. (#424) - Delete `ArgsUtils`, `SgxUtils` and `SgxDriverMode` classes moved to `iexec-commons-containers`. (#426) + ### Dependency Upgrades + - Upgrade to Spring Boot 2.7.14. (#423) - Upgrade to `jenkins-library` 2.7.3. (#425) - Remove `maven-shared-utils` dependency. (#426) @@ -19,61 +39,84 @@ All notable changes to this project will be documented in this file. ## [[8.2.1]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.2.1) 2023-06-23 ### Dependency Upgrades + - Upgrade to `iexec-commons-poco` 3.0.4. (#420) ## [[8.2.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.2.0) 2023-06-05 ### Bug Fixes + - Always use DatasetAddress in `IEXEC_DATASET_FILENAME` environment variable. (#416) + ### Quality + - Mark classes from `com.iexec.common.sdk.order`, `com.iexec.common.sdk.order.payload` and `com.iexec.common.chain.eip712` packages deprecated. (#414 #415) + ### Dependency Upgrades + - Upgrade to `iexec-commons-poco` 3.0.0. (#417) ## [[8.1.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.1.0) 2023-05-11 ### New Features + - Add `CONTRIBUTE_AND_FINALIZE` replicate statuses. (#408) - Add `contributeAndFinalize` related values to `ReplicateStatusCause`. (#411) + ### Bug Fixes + - Log `computedFilePath` instead of `computedFileDir`. (#409) + ### Quality + - Clean unused `ReplicateStatus#RESULT_UPLOAD_REQUEST_FAILED`. (#410) + ### Dependency Upgrades + - Upgrade to `iexec-commons-poco` 2.0.0. (#412) ## [[8.0.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v8.0.0) 2023-04-12 ### Quality + - Deprecate and remove custom Docker implementation in favor of `iexec-commons-containers`. (#388, #389, #390, #391, #392, #393, #394) - Remove `com.iexec.common.sms` package. (#395) - Immutable classes in `com.iexec.common.config` package. (#396) - Immutable classes in `com.iexec.common.sdk.order` package. (#397) - Clean `iexec-common` following `iexec-commons-poco` creation. (#399, #400, #401, #402, #403, #404) + ### Dependency Upgrades + - Upgrade to `jenkins-library` 2.4.0. (#387) - New `iexec-commons-poco` 1.0.2 dependency. (#398, #404) ## [[7.0.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/v7.0.0) 2023-03-02 ### New Features + * Add classes to support Gramine framework for TEE tasks. * Rename `TeeEnclaveProvider` to `TeeFramework`. * Add SMS URL to related task and replicate classes. + ### Bug Fixes + * Disable `notifyJobs` configuration in Jenkinsfile pipeline. * Resolve dependencies from internal Nexus. * Increase app creation gas limit. * Support `provider` alias for `framework` in `TeeEnclaveConfiguration`. * Ignore entrypoint and heap size during Gramine `TeeEnclaveConfiguration` validation. + ### Quality + * Introduce changelog. * Rework Docker implementation and tests. * Remove failed synchronization assertions in tests of `ContextualLockRunner`. * Remove `IexecCli` and `BrokeringEngine`. * Remove unused references. * Remove shadow JAR bundle. + ### Dependency Upgrades + * Upgrade spring-boot-dependencies to 2.6.14. * Upgrade feign dependencies to 11.10. * Upgrade java-multiaddr dependency to v1.4.6. @@ -188,6 +231,7 @@ All notable changes to this project will be documented in this file. ## [[5.0.0]](https://github.com/iExecBlockchainComputing/iexec-common/releases/tag/5.0.0) 2020-07-15 What's merged? + * feature/symlink * feature/stdout-length * feature/clean-stdout-string diff --git a/Jenkinsfile b/Jenkinsfile index 12c705a4..f92538cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,5 @@ -@Library('global-jenkins-library@2.7.3') _ +@Library('global-jenkins-library@2.7.4') _ buildJavaProject( - buildInfo: getBuildInfo(), - integrationTestsEnvVars: [], shouldPublishJars: true, shouldPublishDockerImages: false ) diff --git a/README.md b/README.md index 22355c43..c9942159 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,10 @@ ## Overview The iexec-common library holds classes related to: -* iExec tasks and replicates -* Results of iExec tasks +* iExec replicates +* Results of iExec replicates * Compute model -* Blockchain-related things like - * web3 clients - * iExec Proof-of-Contribution -* Docker client +* Blockchain related things * TEE configurations * Utils tooling diff --git a/build.gradle b/build.gradle index 3fa4970d..835e0d6c 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ repositories { // 'api' configuration allows to expose dependencies with 'compile' scope in pom // 'implementation' configuration allows to expose dependencies with 'runtime' scope in pom dependencies { - implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.14') + implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.17') // feign api "io.github.openfeign:feign-jackson:$openFeignVersion" @@ -91,8 +91,10 @@ dependencies { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(17)) } + sourceCompatibility = "11" + targetCompatibility = "11" withJavadocJar() withSourcesJar() } diff --git a/gradle.properties b/gradle.properties index 3f3dcc09..7a486785 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -version=8.3.0 -iexecCommonsPocoVersion=3.1.0 +version=8.3.1 +iexecCommonsPocoVersion=3.2.0 nexusUser nexusPassword diff --git a/src/main/java/com/iexec/common/chain/eip712/EIP712.java b/src/main/java/com/iexec/common/chain/eip712/EIP712.java deleted file mode 100644 index 710ef70d..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/EIP712.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.web3j.crypto.ECKeyPair; - -import java.util.List; -import java.util.Map; - -@JsonIgnoreProperties(ignoreUnknown = true) -public interface EIP712 { - - @JsonProperty("types") - Map> getTypes(); - - @JsonProperty("domain") - EIP712Domain getDomain(); - - @JsonProperty("primaryType") - String getPrimaryType(); - - @JsonProperty("message") - M getMessage(); - - @JsonIgnore - String getMessageHash(); - - @JsonIgnore - List getMessageTypeParams(); - - @JsonIgnore - String getHash(); - - String signMessage(ECKeyPair ecKeyPair); - -} diff --git a/src/main/java/com/iexec/common/chain/eip712/EIP712Domain.java b/src/main/java/com/iexec/common/chain/eip712/EIP712Domain.java deleted file mode 100644 index bca37732..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/EIP712Domain.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.iexec.commons.poco.utils.HashUtils; -import lombok.Getter; -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Represents the {@code EIP712Domain} part an EIP-712 compliant data structure. - *

- * This class allows to: - *

    - *
  • describe a domain with the correct fields - *
  • represent the domain structure as string like {@code EIP712Domain(string name,string version,unit256 chainId)} - *
  • compute the {@code domainSeparator}, the hash of the concatenation of the domain structure hash and the hash of field values - *
- * @deprecated Use {@link com.iexec.commons.poco.eip712.EIP712Domain} - */ -@Deprecated(forRemoval = true) -@Getter -public class EIP712Domain { - - public static final String primaryType = "EIP712Domain"; - - private final String name; - private final String version; - private final long chainId; - - @JsonInclude(value = JsonInclude.Include.NON_NULL) - private final String verifyingContract; - - public EIP712Domain() { - this("", "", 0L, null); - } - - public EIP712Domain(long chainId, String verifyingContract) { - this("iExecODB", "5.0.0", chainId, verifyingContract); - } - - public EIP712Domain(String name, String version, long chainId, String verifyingContract) { - this.name = name; - this.version = version; - this.chainId = chainId; - this.verifyingContract = verifyingContract; - } - - @JsonIgnore - public List getTypes() { - List types = new ArrayList<>(); - types.addAll(Arrays.asList( - new TypeParam("name", "string"), - new TypeParam("version", "string"), - new TypeParam("chainId", "uint256") - )); - - if (StringUtils.isNotEmpty(this.verifyingContract)) { - types.add( - new TypeParam("verifyingContract", "address")); - } - return types; - } - - /** - * Gets the representation of the EIP712Domain instance. - * @return The {@code EIP712Domain(string name,string version,uint256 chainId,...)} string - */ - @JsonIgnore - public String getDomainType() { - return primaryType + "(" + - getTypes().stream().map(TypeParam::toDescription) - .collect(Collectors.joining(",")) + ")"; - } - - /** - * Gets the {@code domainSeparator} of an EIP-712 compliant data structure. - *

- * It concatenates the hash of {@link #getDomainType()} and the hash of each field value for the current instance. - * The result of this concatenation is then hashed. - * @return The computed hash. - */ - @JsonIgnore - public String getDomainSeparator() { - String domainType = getDomainType(); - - if (StringUtils.isNotEmpty(this.verifyingContract)) { - return HashUtils.concatenateAndHash( - EIP712Utils.encodeData(domainType), - EIP712Utils.encodeData(name), - EIP712Utils.encodeData(version), - EIP712Utils.encodeData(chainId), - EIP712Utils.encodeData(verifyingContract)); - } - - return HashUtils.concatenateAndHash( - EIP712Utils.encodeData(domainType), - EIP712Utils.encodeData(name), - EIP712Utils.encodeData(version), - EIP712Utils.encodeData(chainId)); - } - -} diff --git a/src/main/java/com/iexec/common/chain/eip712/EIP712Entity.java b/src/main/java/com/iexec/common/chain/eip712/EIP712Entity.java deleted file mode 100644 index cc4c319a..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/EIP712Entity.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.google.common.collect.ObjectArrays; -import com.iexec.commons.poco.utils.HashUtils; -import com.iexec.commons.poco.utils.SignatureUtils; -import lombok.NoArgsConstructor; -import org.web3j.crypto.ECKeyPair; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.EIP712Entity} - */ -@Deprecated(forRemoval = true) -@NoArgsConstructor -public abstract class EIP712Entity implements EIP712 { - - private Map> types; - private EIP712Domain domain; - private M message; - - protected EIP712Entity(EIP712Domain domain, M message) { - this.domain = domain; - this.message = message; - this.types = Map.of( - EIP712Domain.primaryType, domain.getTypes(), - getPrimaryType(), getMessageTypeParams() - ); - } - - @Override - public Map> getTypes() { - return new HashMap<>(types); - } - - @Override - public EIP712Domain getDomain() { - return domain; - } - - @Override - public M getMessage() { - return message; - } - - @Override - public String getHash() { - return HashUtils.concatenateAndHash( - "0x1901", - getDomain().getDomainSeparator(), - getMessageHash()); - } - - public String hashMessageValues(Object... values) { - String type = getPrimaryType() + "(" + getMessageTypeParams().stream() - .map(TypeParam::toDescription) - .collect(Collectors.joining(",")) + ")"; - //MyEntity(address param1, string param2, ..) - String typeHash = EIP712Utils.encodeData(type); - String[] encodedValues = Arrays.stream(values).map(EIP712Utils::encodeData).toArray(String[]::new); - return HashUtils.concatenateAndHash(ObjectArrays.concat(typeHash, encodedValues)); - } - - public String signMessage(ECKeyPair ecKeyPair) { - return SignatureUtils.signAsString(this.getHash(), ecKeyPair); - } - - @JsonIgnore - public List getDomainTypeParams() { - return new ArrayList<>(types.get(EIP712Domain.primaryType)); - } -} diff --git a/src/main/java/com/iexec/common/chain/eip712/EIP712Utils.java b/src/main/java/com/iexec/common/chain/eip712/EIP712Utils.java deleted file mode 100644 index 0964534d..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/EIP712Utils.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.iexec.commons.poco.utils.BytesUtils; -import org.web3j.crypto.Hash; -import org.web3j.utils.Numeric; - -import java.math.BigInteger; - -/** - * See https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26 - */ -public class EIP712Utils { - - private EIP712Utils() { - throw new UnsupportedOperationException(); - } - - public static String encodeData(Object param) { - if (param.getClass().equals(String.class)) { - if (Numeric.containsHexPrefix((String) param)) { - return encodeHexString((String) param); // 0x < bytes32 - } else { - return encodeUTF8String((String) param); // ascii - } - } else if (param.getClass().equals(Long.class)) { - return encodeLong((Long) param); - } else if (param.getClass().equals(BigInteger.class)) { - return encodeBigInteger((BigInteger) param); - } else if (param.getClass().equals(byte[].class)) { - return encodeByteArray((byte[]) param); - } - return ""; - } - - static String encodeUTF8String(String string) { - return Hash.sha3String(string); - } - - static String encodeHexString(String hexString) { - if (!BytesUtils.isHexString(hexString)) { - return ""; - } - if (BytesUtils.stringToBytes(hexString).length > 32) { - return ""; - } - return Numeric.toHexString(Numeric.toBytesPadded(Numeric.toBigInt(hexString), 32)); - } - - static String encodeLong(Long longValue) { - return Numeric.toHexString(Numeric.toBytesPadded(BigInteger.valueOf(longValue), 32)); - } - - static String encodeBigInteger(BigInteger bigInteger) { - return Numeric.toHexString(Numeric.toBytesPadded(bigInteger, 32)); - } - - static String encodeByteArray(byte[] byteArray) { - if (byteArray == null || byteArray.length != BytesUtils.BYTES_32_SIZE) { - return ""; - } - return Numeric.toHexString(byteArray); - } - - /* - * REMINDER : Arrays.concatenate(byteArray) similar to Numeric.hexStringToByteArray("0x1901") - * - * abi.encode should take bytes32 (padding could be required) while abi.encodePacked takes 0x12+1a2b - * - * System.out.println(Numeric.toHexString(Arrays.concatenate(Numeric.hexStringToByteArray("1901"), - * Numeric.hexStringToByteArray(domainSeparator) , - * Numeric.hexStringToByteArray(messageHash))).equals(Numeric.toHexString(Numeric.hexStringToByteArray( - * "0x1901" + Numeric.cleanHexPrefix(domainSeparator) + Numeric.cleanHexPrefix(messageHash))))); - * - */ -} diff --git a/src/main/java/com/iexec/common/chain/eip712/TypeParam.java b/src/main/java/com/iexec/common/chain/eip712/TypeParam.java deleted file mode 100644 index 160cae63..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/TypeParam.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Describe a single member of a struct in an EIP-712 compliant data types description. - *

- * This is part of {@code typeHash = keccak256(encodeType(typeOf(s)))} where {@code encodeType} is - * {@code structName(paramType<1> paramName<1>,...,paramType paramName)}. - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class TypeParam { - - private String name; - private String type; - - /** - * Gets the description of a single parameter as a String. - * @return The {@code " "} string - */ - public String toDescription() { - return type + " " + name; - } - -} diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/Challenge.java b/src/main/java/com/iexec/common/chain/eip712/entity/Challenge.java deleted file mode 100644 index 35555198..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/Challenge.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Represents the Challenge type in an EIP-712 compliant challenge. - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.Challenge} - */ -@Deprecated(forRemoval = true) -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Challenge { - private String challenge; -} diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712AppOrder.java b/src/main/java/com/iexec/common/chain/eip712/entity/EIP712AppOrder.java deleted file mode 100644 index 18f8a4d7..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712AppOrder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.EIP712Entity; -import com.iexec.commons.poco.eip712.TypeParam; -import com.iexec.commons.poco.order.AppOrder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Arrays; -import java.util.List; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.EIP712AppOrder} - */ -@Deprecated(forRemoval = true) -@Getter -@NoArgsConstructor -public class EIP712AppOrder extends EIP712Entity { - - public EIP712AppOrder(EIP712Domain domain, AppOrder appOrder) { - super(domain, appOrder); - } - - @Override - public String getPrimaryType() { - return "AppOrder"; - } - - @Override - public List getMessageTypeParams() { - return Arrays.asList( - new TypeParam("app", "address"), - new TypeParam("appprice", "uint256"), - new TypeParam("volume", "uint256"), - new TypeParam("tag", "bytes32"), - new TypeParam("datasetrestrict", "address"), - new TypeParam("workerpoolrestrict", "address"), - new TypeParam("requesterrestrict", "address"), - new TypeParam("salt", "bytes32")); - } - - @Override - public String getMessageHash() { - return super.hashMessageValues( - getMessage().getApp(), - getMessage().getAppprice(), - getMessage().getVolume(), - getMessage().getTag(), - getMessage().getDatasetrestrict(), - getMessage().getWorkerpoolrestrict(), - getMessage().getRequesterrestrict(), - getMessage().getSalt() - ); - } - -} \ No newline at end of file diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712Challenge.java b/src/main/java/com/iexec/common/chain/eip712/entity/EIP712Challenge.java deleted file mode 100644 index 6de0d1f0..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712Challenge.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2022 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.EIP712Entity; -import com.iexec.commons.poco.eip712.TypeParam; -import lombok.NoArgsConstructor; - -import java.util.Collections; -import java.util.List; - -/** - * EIP-712 compliant challenge based on {@link Challenge} type and {@link EIP712Domain}. - *

- * In the current implementation, {@link EIP712Domain} fields are {@code name}, {@code version} and {@code chainID}. - * There is no {@code verifyingContract}. - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.EIP712Challenge} - */ -@Deprecated(forRemoval = true) -@NoArgsConstructor -public class EIP712Challenge extends EIP712Entity { - - public EIP712Challenge(EIP712Domain domain, Challenge message) { - super(domain, message); - } - - public String getPrimaryType() { - return "Challenge"; - } - - @Override - public List getMessageTypeParams() { - return Collections.singletonList( - new TypeParam("challenge", "string") - ); - } - - @Override - public String getMessageHash() { - return super.hashMessageValues( - getMessage().getChallenge() - ); - } - -} diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrder.java b/src/main/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrder.java deleted file mode 100644 index 000adedd..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.EIP712Entity; -import com.iexec.commons.poco.eip712.TypeParam; -import com.iexec.commons.poco.order.DatasetOrder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Arrays; -import java.util.List; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.EIP712DatasetOrder} - */ -@Deprecated(forRemoval = true) -@Getter -@NoArgsConstructor -public class EIP712DatasetOrder extends EIP712Entity { - - public EIP712DatasetOrder(EIP712Domain domain, DatasetOrder datasetOrder) { - super(domain, datasetOrder); - } - - @Override - public String getPrimaryType() { - return "DatasetOrder"; - } - - @Override - public List getMessageTypeParams() { - return Arrays.asList( - new TypeParam("dataset", "address"), - new TypeParam("datasetprice", "uint256"), - new TypeParam("volume", "uint256"), - new TypeParam("tag", "bytes32"), - new TypeParam("apprestrict", "address"), - new TypeParam("workerpoolrestrict", "address"), - new TypeParam("requesterrestrict", "address"), - new TypeParam("salt", "bytes32")); - } - - @Override - public String getMessageHash() { - return super.hashMessageValues( - getMessage().getDataset(), - getMessage().getDatasetprice(), - getMessage().getVolume(), - getMessage().getTag(), - getMessage().getApprestrict(), - getMessage().getWorkerpoolrestrict(), - getMessage().getRequesterrestrict(), - getMessage().getSalt() - ); - } - -} \ No newline at end of file diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrder.java b/src/main/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrder.java deleted file mode 100644 index 59d2fb77..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrder.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.EIP712Entity; -import com.iexec.commons.poco.eip712.TypeParam; -import com.iexec.commons.poco.order.RequestOrder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Arrays; -import java.util.List; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.EIP712RequestOrder} - */ -@Deprecated(forRemoval = true) -@Getter -@NoArgsConstructor -public class EIP712RequestOrder extends EIP712Entity { - - public EIP712RequestOrder(EIP712Domain domain, RequestOrder requestOrder) { - super(domain, requestOrder); - } - - @Override - public String getPrimaryType() { - return "RequestOrder"; - } - - @Override - public List getMessageTypeParams() { - return Arrays.asList( - new TypeParam("app", "address"), - new TypeParam("appmaxprice", "uint256"), - new TypeParam("dataset", "address"), - new TypeParam("datasetmaxprice", "uint256"), - new TypeParam("workerpool", "address"), - new TypeParam("workerpoolmaxprice", "uint256"), - new TypeParam("requester", "address"), - new TypeParam("volume", "uint256"), - new TypeParam("tag", "bytes32"), - new TypeParam("category", "uint256"), - new TypeParam("trust", "uint256"), - new TypeParam("beneficiary", "address"), - new TypeParam("callback", "address"), - new TypeParam("params", "string"), - new TypeParam("salt", "bytes32")); - } - - @Override - public String getMessageHash() { - return super.hashMessageValues( - getMessage().getApp(), - getMessage().getAppmaxprice(), - getMessage().getDataset(), - getMessage().getDatasetmaxprice(), - getMessage().getWorkerpool(), - getMessage().getWorkerpoolmaxprice(), - getMessage().getRequester(), - getMessage().getVolume(), - getMessage().getTag(), - getMessage().getCategory(), - getMessage().getTrust(), - getMessage().getBeneficiary(), - getMessage().getCallback(), - getMessage().getParams(), - getMessage().getSalt() - ); - } - -} \ No newline at end of file diff --git a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrder.java b/src/main/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrder.java deleted file mode 100644 index bd7060fb..00000000 --- a/src/main/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.EIP712Entity; -import com.iexec.commons.poco.eip712.TypeParam; -import com.iexec.commons.poco.order.WorkerpoolOrder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Arrays; -import java.util.List; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.entity.EIP712WorkerpoolOrder} - */ -@Deprecated(forRemoval = true) -@Getter -@NoArgsConstructor -public class EIP712WorkerpoolOrder extends EIP712Entity { - - public EIP712WorkerpoolOrder(EIP712Domain domain, WorkerpoolOrder workerpoolOrder) { - super(domain, workerpoolOrder); - } - - @Override - public String getPrimaryType() { - return "WorkerpoolOrder"; - } - - @Override - public List getMessageTypeParams() { - return Arrays.asList( - new TypeParam("workerpool", "address"), - new TypeParam("workerpoolprice", "uint256"), - new TypeParam("volume", "uint256"), - new TypeParam("tag", "bytes32"), - new TypeParam("category", "uint256"), - new TypeParam("trust", "uint256"), - new TypeParam("apprestrict", "address"), - new TypeParam("datasetrestrict", "address"), - new TypeParam("requesterrestrict", "address"), - new TypeParam("salt", "bytes32")); - } - - @Override - public String getMessageHash() { - return super.hashMessageValues( - getMessage().getWorkerpool(), - getMessage().getWorkerpoolprice(), - getMessage().getVolume(), - getMessage().getTag(), - getMessage().getCategory(), - getMessage().getTrust(), - getMessage().getApprestrict(), - getMessage().getDatasetrestrict(), - getMessage().getRequesterrestrict(), - getMessage().getSalt() - ); - } - -} \ No newline at end of file diff --git a/src/main/java/com/iexec/common/sdk/order/OrderSigner.java b/src/main/java/com/iexec/common/sdk/order/OrderSigner.java deleted file mode 100644 index 50a82c66..00000000 --- a/src/main/java/com/iexec/common/sdk/order/OrderSigner.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order; - -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.entity.EIP712AppOrder; -import com.iexec.commons.poco.eip712.entity.EIP712DatasetOrder; -import com.iexec.commons.poco.eip712.entity.EIP712RequestOrder; -import com.iexec.commons.poco.eip712.entity.EIP712WorkerpoolOrder; -import com.iexec.commons.poco.order.AppOrder; -import com.iexec.commons.poco.order.DatasetOrder; -import com.iexec.commons.poco.order.RequestOrder; -import com.iexec.commons.poco.order.WorkerpoolOrder; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.web3j.crypto.ECKeyPair; - -/** - * @deprecated Use {@link com.iexec.commons.poco.eip712.OrderSigner} - */ -@Slf4j -@Deprecated(forRemoval = true) -public class OrderSigner { - - private final EIP712Domain eip712Domain; - private final ECKeyPair ecKeyPair; - - public OrderSigner( - int chainId, - String verifyingContract, - ECKeyPair ecKeyPair - ) { - this.ecKeyPair = ecKeyPair; - eip712Domain = new EIP712Domain(chainId, verifyingContract); - } - - public AppOrder signAppOrder(AppOrder appOrder) { - if (appOrder == null) { - return null; - } - String signature = new EIP712AppOrder(eip712Domain, appOrder) - .signMessage(ecKeyPair); - if (StringUtils.isEmpty(signature)) { - log.error("Empty signature [appOrder:{}]", appOrder); - return null; - } - return appOrder.withSignature(signature); - } - - public WorkerpoolOrder signWorkerpoolOrder(WorkerpoolOrder workerpoolOrder) { - if (workerpoolOrder == null) { - return null; - } - String signature = new EIP712WorkerpoolOrder(eip712Domain, workerpoolOrder) - .signMessage(ecKeyPair); - if (StringUtils.isEmpty(signature)) { - log.error("Empty signature [workerpoolOrder:{}]", workerpoolOrder); - return null; - } - return workerpoolOrder.withSignature(signature); - } - - public DatasetOrder signDatasetOrder(DatasetOrder datasetOrder) { - if (datasetOrder == null) { - return null; - } - String signature = new EIP712DatasetOrder(eip712Domain, datasetOrder) - .signMessage(ecKeyPair); - if (StringUtils.isEmpty(signature)) { - log.error("Empty signature [datasetOrder:{}]", datasetOrder); - return null; - } - return datasetOrder.withSignature(signature); - } - - public RequestOrder signRequestOrder(RequestOrder requestOrder) { - if (requestOrder == null) { - return null; - } - String signature = new EIP712RequestOrder(eip712Domain, requestOrder) - .signMessage(ecKeyPair); - if (StringUtils.isEmpty(signature)) { - log.error("Empty signature [requestOrder:{}]", requestOrder); - return null; - } - return requestOrder.withSignature(signature); - } -} diff --git a/src/main/java/com/iexec/common/sdk/order/OrderTag.java b/src/main/java/com/iexec/common/sdk/order/OrderTag.java deleted file mode 100644 index ec5f3b7c..00000000 --- a/src/main/java/com/iexec/common/sdk/order/OrderTag.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order; - -import com.iexec.commons.poco.tee.TeeUtils; -import com.iexec.commons.poco.utils.BytesUtils; -import lombok.Getter; - -/** - * @deprecated Use {@link com.iexec.commons.poco.order.OrderTag} - */ -@Getter -@Deprecated(forRemoval = true) -public enum OrderTag { - - STANDARD(BytesUtils.EMPTY_HEX_STRING_32), - TEE_SCONE(TeeUtils.TEE_SCONE_ONLY_TAG), - TEE_GRAMINE(TeeUtils.TEE_GRAMINE_ONLY_TAG); - - private final String value; - - OrderTag(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - -} diff --git a/src/main/java/com/iexec/common/sdk/order/payload/AppOrder.java b/src/main/java/com/iexec/common/sdk/order/payload/AppOrder.java deleted file mode 100644 index ef49cff6..00000000 --- a/src/main/java/com/iexec/common/sdk/order/payload/AppOrder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.Value; - -import java.math.BigInteger; - -/** - * @deprecated Use {@link com.iexec.commons.poco.order.AppOrder} - */ -@Deprecated(forRemoval = true) -@Value -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@JsonDeserialize(builder = AppOrder.AppOrderBuilder.class) -public class AppOrder extends Order { - - String app; - BigInteger appprice; - String datasetrestrict; - String workerpoolrestrict; - String requesterrestrict; - - @Builder - AppOrder( - String app, - BigInteger appprice, - BigInteger volume, - String tag, - String salt, - String sign, - String datasetrestrict, - String workerpoolrestrict, - String requesterrestrict) { - super(volume, tag, salt, sign); - this.app = app; - this.appprice = appprice; - this.datasetrestrict = toLowerCase(datasetrestrict); - this.workerpoolrestrict = toLowerCase(workerpoolrestrict); - this.requesterrestrict = toLowerCase(requesterrestrict); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class AppOrderBuilder{} - - @Override - public AppOrder withSignature(String signature) { - return new AppOrder( - this.app, this.appprice, - this.volume, this.tag, this.salt, signature, - this.datasetrestrict, this.workerpoolrestrict, this.requesterrestrict - ); - } -} diff --git a/src/main/java/com/iexec/common/sdk/order/payload/DatasetOrder.java b/src/main/java/com/iexec/common/sdk/order/payload/DatasetOrder.java deleted file mode 100644 index cfb0241d..00000000 --- a/src/main/java/com/iexec/common/sdk/order/payload/DatasetOrder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.Value; - -import java.math.BigInteger; - -/** - * @deprecated Use {@link com.iexec.commons.poco.order.DatasetOrder} - */ -@Deprecated(forRemoval = true) -@Value -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@JsonDeserialize(builder = DatasetOrder.DatasetOrderBuilder.class) -public class DatasetOrder extends Order { - - String dataset; - BigInteger datasetprice; - String apprestrict; - String workerpoolrestrict; - String requesterrestrict; - - @Builder - DatasetOrder( - String dataset, - BigInteger datasetprice, - BigInteger volume, - String tag, - String salt, - String sign, - String apprestrict, - String workerpoolrestrict, - String requesterrestrict) { - super(volume, tag, salt, sign); - this.dataset = dataset; - this.datasetprice = datasetprice; - this.apprestrict = toLowerCase(apprestrict); - this.workerpoolrestrict = toLowerCase(workerpoolrestrict); - this.requesterrestrict = toLowerCase(requesterrestrict); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class DatasetOrderBuilder{} - - public DatasetOrder withSignature(String signature) { - return new DatasetOrder( - this.dataset, this.datasetprice, - this.volume, this.tag, this.salt, signature, - this.apprestrict, this.workerpoolrestrict, this.requesterrestrict - ); - } -} diff --git a/src/main/java/com/iexec/common/sdk/order/payload/Order.java b/src/main/java/com/iexec/common/sdk/order/payload/Order.java deleted file mode 100644 index 58855906..00000000 --- a/src/main/java/com/iexec/common/sdk/order/payload/Order.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.math.BigInteger; - -@Getter -@AllArgsConstructor(access = AccessLevel.PROTECTED) -public abstract class Order { - - BigInteger volume; - String tag; - String salt; - String sign; - - @JsonIgnore - public boolean isSigned() { - return sign != null && !sign.isEmpty(); - } - - /** - * Converts all characters to Lowercase or returns empty - * @param s String to convert - * @return the String, converted to lowercase or an empty string - */ - public String toLowerCase(String s) { - return s != null ? s.toLowerCase() : ""; - } - - public abstract Order withSignature(String signature); - -} - diff --git a/src/main/java/com/iexec/common/sdk/order/payload/RequestOrder.java b/src/main/java/com/iexec/common/sdk/order/payload/RequestOrder.java deleted file mode 100644 index cbd0fb88..00000000 --- a/src/main/java/com/iexec/common/sdk/order/payload/RequestOrder.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.Value; - -import java.math.BigInteger; -import java.util.Objects; - -/** - * @deprecated Use {@link com.iexec.commons.poco.order.RequestOrder} - */ -@Deprecated(forRemoval = true) -@Value -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@JsonDeserialize(builder = RequestOrder.RequestOrderBuilder.class) -public class RequestOrder extends Order { - - String app; - BigInteger appmaxprice; - String dataset; - BigInteger datasetmaxprice; - String workerpool; - BigInteger workerpoolmaxprice; - String requester; - BigInteger category; - BigInteger trust; - String beneficiary; - String callback; - String params; - - @Builder - RequestOrder( - String app, - BigInteger appmaxprice, - String dataset, - BigInteger datasetmaxprice, - String workerpool, - BigInteger workerpoolmaxprice, - String requester, - BigInteger volume, - String tag, - BigInteger category, - BigInteger trust, - String beneficiary, - String callback, - String params, - String salt, - String sign) { - super(volume, tag, salt, sign); - this.app = toLowerCase(app); - this.appmaxprice = appmaxprice; - this.dataset = toLowerCase(dataset); - this.datasetmaxprice = datasetmaxprice; - this.workerpool = toLowerCase(workerpool); - this.workerpoolmaxprice = workerpoolmaxprice; - this.requester = toLowerCase(requester); - this.category = category; - this.trust = trust; - this.beneficiary = toLowerCase(beneficiary); - this.callback = toLowerCase(callback); - this.params = params; - } - - public boolean equalsExcludedSaltSignAndParams(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RequestOrder that = (RequestOrder) o; - return Objects.equals(app, that.app) && - Objects.equals(appmaxprice, that.appmaxprice) && - Objects.equals(dataset, that.dataset) && - Objects.equals(datasetmaxprice, that.datasetmaxprice) && - Objects.equals(workerpool, that.workerpool) && - Objects.equals(workerpoolmaxprice, that.workerpoolmaxprice) && - Objects.equals(volume, that.volume) && - Objects.equals(category, that.category) && - Objects.equals(trust, that.trust) && - Objects.equals(tag, that.tag) && - Objects.equals(beneficiary, that.beneficiary) && - Objects.equals(callback, that.callback) && - //Objects.equals(params, that.params) && - Objects.equals(requester, that.requester); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class RequestOrderBuilder{} - - @Override - public RequestOrder withSignature(String signature) { - return new RequestOrder( - this.app, this.appmaxprice, - this.dataset, this.datasetmaxprice, - this.workerpool, this.workerpoolmaxprice, - this.requester, this.volume, this.tag, this.category, - this.trust, this.beneficiary, this.callback, this.params, this.salt, signature - ); - } -} diff --git a/src/main/java/com/iexec/common/sdk/order/payload/WorkerpoolOrder.java b/src/main/java/com/iexec/common/sdk/order/payload/WorkerpoolOrder.java deleted file mode 100644 index dd99beb4..00000000 --- a/src/main/java/com/iexec/common/sdk/order/payload/WorkerpoolOrder.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.Value; - -import java.math.BigInteger; - -/** - * @deprecated Use {@link com.iexec.commons.poco.order.WorkerpoolOrder} - */ -@Deprecated(forRemoval = true) -@Value -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@JsonDeserialize(builder = WorkerpoolOrder.WorkerpoolOrderBuilder.class) -public class WorkerpoolOrder extends Order { - - String workerpool; - BigInteger workerpoolprice; - BigInteger trust; - BigInteger category; - String apprestrict; - String datasetrestrict; - String requesterrestrict; - - @Builder - WorkerpoolOrder( - String workerpool, - BigInteger workerpoolprice, - BigInteger volume, - String tag, - BigInteger trust, - BigInteger category, - String salt, - String sign, - String apprestrict, - String datasetrestrict, - String requesterrestrict) { - super(volume, tag, salt, sign); - this.workerpool = workerpool; - this.workerpoolprice = workerpoolprice; - this.trust = trust; - this.category = category; - this.apprestrict = toLowerCase(apprestrict); - this.datasetrestrict = toLowerCase(datasetrestrict); - this.requesterrestrict = toLowerCase(requesterrestrict); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class WorkerpoolOrderBuilder{} - - @Override - public WorkerpoolOrder withSignature(String signature) { - return new WorkerpoolOrder( - this.workerpool, this.workerpoolprice, - this.volume, this.tag, this.trust, this.category, this.salt, signature, - this.apprestrict, this.datasetrestrict, this.requesterrestrict - ); - } -} diff --git a/src/test/java/com/iexec/common/chain/eip712/EIP712DomainTest.java b/src/test/java/com/iexec/common/chain/eip712/EIP712DomainTest.java deleted file mode 100644 index 1d11e377..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/EIP712DomainTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2021-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.utils.HashUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.Hash; -import org.web3j.utils.Numeric; - -import java.math.BigInteger; -import java.nio.charset.StandardCharsets; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712DomainTest { - - private static final String DOMAIN_NAME = "iExec Custom Module Domain"; - private static final String DOMAIN_VERSION = "1"; - private static final long DOMAIN_CHAIN_ID = 2; - private static final String DOMAIN_VERIFYING_CONTRACT = "0x0000000000000000000000000000000000000001"; - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldGetDomainWithVerifyingContract() throws JsonProcessingException { - EIP712Domain domain = - new EIP712Domain(DOMAIN_NAME, DOMAIN_VERSION, DOMAIN_CHAIN_ID, DOMAIN_VERIFYING_CONTRACT); - String jsonString = mapper.writeValueAsString(domain); - assertThat(jsonString) - .isEqualTo("{" + - "\"name\":\"iExec Custom Module Domain\"," + - "\"version\":\"1\"," + - "\"chainId\":2," + - "\"verifyingContract\":\"0x0000000000000000000000000000000000000001\"}"); - assertThat(domain.getDomainType()) - .isEqualTo("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); - String domainSeparator = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(domain.getDomainType().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Hash.sha3(domain.getName().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Hash.sha3(domain.getVersion().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Numeric.toBytesPadded(BigInteger.valueOf(domain.getChainId()), 32)), - Numeric.toHexString(Numeric.toBytesPadded(Numeric.toBigInt(domain.getVerifyingContract()), 32))); - assertThat(domain.getDomainSeparator()) - .isEqualTo(domainSeparator) - .isEqualTo("0xb3b1dcc957351eff67866cbc947be104a71d09ff7e146a2c42e8f7edc2bf501c"); - EIP712Domain deserializedDomain = mapper.readValue(jsonString, EIP712Domain.class); - assertThat(deserializedDomain) - .usingRecursiveComparison() - .isEqualTo(domain); - } - - @Test - void shouldGetDomainWithoutVerifyingContract() throws JsonProcessingException { - EIP712Domain domain = - new EIP712Domain(DOMAIN_NAME, DOMAIN_VERSION, DOMAIN_CHAIN_ID, null); - String jsonString = mapper.writeValueAsString(domain); - assertThat(jsonString) - .isEqualTo("{" + - "\"name\":\"iExec Custom Module Domain\"," + - "\"version\":\"1\"," + - "\"chainId\":2" + - "}"); - assertThat(domain.getDomainType()) - .isEqualTo("EIP712Domain(string name,string version,uint256 chainId)"); - String domainSeparator = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(domain.getDomainType().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Hash.sha3(domain.getName().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Hash.sha3(domain.getVersion().getBytes(StandardCharsets.UTF_8))), - Numeric.toHexString(Numeric.toBytesPadded(BigInteger.valueOf(domain.getChainId()), 32))); - assertThat(domain.getDomainSeparator()) - .isEqualTo(domainSeparator) - .isEqualTo("0xc1ca0800eccc218e09b4b90ca3ba732ee9a923d115f880316caf56c466c0bc34"); - EIP712Domain deserializedDomain = mapper.readValue(jsonString, EIP712Domain.class); - assertThat(deserializedDomain) - .usingRecursiveComparison() - .isEqualTo(domain); - } - -} diff --git a/src/test/java/com/iexec/common/chain/eip712/EIP712UtilsTest.java b/src/test/java/com/iexec/common/chain/eip712/EIP712UtilsTest.java deleted file mode 100644 index 16927146..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/EIP712UtilsTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712; - -import com.iexec.commons.poco.utils.BytesUtils; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.math.BigInteger; - -class EIP712UtilsTest { - - @Test - void encodeUTF8String() { - String someText = "some text"; - Assertions.assertThat(EIP712Utils.encodeData(someText)) - .isEqualTo(EIP712Utils.encodeUTF8String(someText)) - .isEqualTo("0x46ba1b442d3606a3437800ee7ae5a0249756405e676739b46aa8f6e85b13fe2b"); - } - - @Test - void encodeHexString() { - String param = "0x000000000000000000000000000000000000000000000000000000000000000a"; - Assertions.assertThat(EIP712Utils.encodeData(param)) - .isEqualTo(EIP712Utils.encodeHexString(param)) - .isEqualTo(param); - } - - @Test - void encodeHexStringIfLowerThanBytes32() { - String param = "0x0a"; - Assertions.assertThat(EIP712Utils.encodeData(param)) - .isEqualTo(EIP712Utils.encodeHexString(param)) - .isEqualTo("0x000000000000000000000000000000000000000000000000000000000000000a"); - } - - @Test - void shouldNotEncodeHexStringSinceNotHex() { - String param = "xyz"; - Assertions.assertThat(EIP712Utils.encodeHexString(param)).isEmpty(); - } - - @Test - void shouldNotEncodeHexStringSinceMoreThanBytes32() { - String param = "0x000000000000000000000000000000000000000000000000000000000000000a" + "0b"; - Assertions.assertThat(EIP712Utils.encodeHexString(param)).isEmpty(); - } - - @Test - void encodeLong() { - Long param = 11L; - Assertions.assertThat(EIP712Utils.encodeData(param)) - .isEqualTo(EIP712Utils.encodeLong(param)) - .isEqualTo("0x000000000000000000000000000000000000000000000000000000000000000b"); - } - - @Test - void encodeBigInteger() { - BigInteger param = BigInteger.valueOf(12); - Assertions.assertThat(EIP712Utils.encodeData(param)) - .isEqualTo(EIP712Utils.encodeBigInteger(param)) - .isEqualTo("0x000000000000000000000000000000000000000000000000000000000000000c"); - } - - @Test - void encodeByteArray() { - String param = "0x000000000000000000000000000000000000000000000000000000000000000d"; - Assertions.assertThat(EIP712Utils.encodeData(BytesUtils.stringToBytes(param))) - .isEqualTo(EIP712Utils.encodeByteArray(BytesUtils.stringToBytes(param))) - .isEqualTo(param); - } - - @Test - void shouldNotEncodeByteArraySinceNotBytes32() { - String param = "0x0a"; - Assertions.assertThat(EIP712Utils.encodeByteArray(BytesUtils.stringToBytes(param))).isEmpty(); - } -} diff --git a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712AppOrderTest.java b/src/test/java/com/iexec/common/chain/eip712/entity/EIP712AppOrderTest.java deleted file mode 100644 index 7f295479..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712AppOrderTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.order.AppOrder; -import com.iexec.commons.poco.utils.BytesUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.CipherException; -import org.web3j.crypto.ECKeyPair; -import org.web3j.crypto.WalletUtils; - -import java.io.IOException; -import java.math.BigInteger; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712AppOrderTest { - - private static final ObjectMapper mapper = new ObjectMapper(); - private static final EIP712Domain DOMAIN = new EIP712Domain(133, "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"); - private static final AppOrder APP_ORDER = AppOrder.builder() - .app("0x2EbD509d777B187E8394566bA6ec093B9dd73DF1") - .appprice(BigInteger.valueOf(0)) - .volume(BigInteger.valueOf(1)) - .tag("0x0000000000000000000000000000000000000000000000000000000000000000") - .datasetrestrict(BytesUtils.EMPTY_ADDRESS) - .workerpoolrestrict(BytesUtils.EMPTY_ADDRESS) - .requesterrestrict(BytesUtils.EMPTY_ADDRESS) - .salt("0xbe858b0eee90cf2e85297bd3df81373f6b4de20c67a3e1f5db1a9d5be8abc3c4") - .build(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - EIP712AppOrder eip712AppOrder = new EIP712AppOrder(DOMAIN, APP_ORDER); - String jsonString = mapper.writeValueAsString(eip712AppOrder); - EIP712AppOrder deserializedEip712AppOrder = mapper.readValue(jsonString, EIP712AppOrder.class); - assertThat(deserializedEip712AppOrder).usingRecursiveComparison().isEqualTo(eip712AppOrder); - } - - /** - * Expected signature string could also be found with: - *

- * iexec order sign --app --chain 133 \ - * --keystoredir /home/$USER/iexecdev/iexec-common/src/test/resources/ \ - * --wallet-file wallet.json --password whatever - *

- * Note: Don't forget to update salt - */ - @Test - void signAppOrderEIP712() { - EIP712AppOrder eip712AppOrder = new EIP712AppOrder(DOMAIN, APP_ORDER); - String signatureString = eip712AppOrder.signMessage(getWallet()); - assertThat(signatureString) - .isEqualTo("0xb1d87561e2358d0f2f3f305562f47da8a053faa179b00a534405996da5ff20e63cabc35e204619d95e9e8b431ad30c7e0f95f189860821b8066b13da896f15ee1b"); - } - - private ECKeyPair getWallet() { - try { - return WalletUtils.loadCredentials( - "whatever", - "./src/test/resources/wallet.json") - .getEcKeyPair(); - } catch (IOException | CipherException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712ChallengeTests.java b/src/test/java/com/iexec/common/chain/eip712/entity/EIP712ChallengeTests.java deleted file mode 100644 index 683527c3..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712ChallengeTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2022-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.eip712.TypeParam; -import com.iexec.commons.poco.utils.HashUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.Hash; -import org.web3j.utils.Numeric; - -import java.math.BigInteger; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712ChallengeTests { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - Challenge challenge = Challenge.builder().challenge("challenge").build(); - EIP712Domain domain = new EIP712Domain(); - EIP712Challenge eip712Challenge = new EIP712Challenge(domain, challenge); - String jsonString = mapper.writeValueAsString(eip712Challenge); - EIP712Challenge deserializedChallenge = mapper.readValue(jsonString, EIP712Challenge.class); - assertThat(deserializedChallenge).usingRecursiveComparison().isEqualTo(eip712Challenge); - } - - @Test - void shouldReturnJsonString() throws JsonProcessingException { - Challenge challenge = Challenge.builder().challenge("challenge").build(); - EIP712Domain domain = new EIP712Domain("COMMON", "1", 15L, null); - EIP712Challenge eip712Challenge = new EIP712Challenge(domain, challenge); - assertThat(mapper.writeValueAsString(eip712Challenge)) - .isNotEmpty() - .isEqualTo("{\"types\":{\"EIP712Domain\":[" + - "{\"name\":\"name\",\"type\":\"string\"}," + - "{\"name\":\"version\",\"type\":\"string\"}," + - "{\"name\":\"chainId\",\"type\":\"uint256\"}" + - "]," + - "\"Challenge\":[{\"name\":\"challenge\",\"type\":\"string\"}]}," + - "\"domain\":{\"name\":\"COMMON\",\"version\":\"1\",\"chainId\":15}," + - "\"message\":{\"challenge\":\"challenge\"}," + - "\"primaryType\":\"Challenge\"}"); - String domainType = "EIP712Domain(string name,string version,uint256 chainId)"; - String domainSeparator = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(domainType.getBytes())), - Numeric.toHexString(Hash.sha3(domain.getName().getBytes())), - Numeric.toHexString(Hash.sha3(domain.getVersion().getBytes())), - Numeric.toHexString(Numeric.toBytesPadded(BigInteger.valueOf(domain.getChainId()), 32))); - assertThat(eip712Challenge.getDomain().getDomainSeparator()) - .isEqualTo(domainSeparator) - .isEqualTo("0x032ca689dd6e3f3369c7a74aae8b74a5cf8d5deb2511d68755eed205595e57a5"); - String messageType = "Challenge(string challenge)"; - String messageHash = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(messageType.getBytes())), - Numeric.toHexString(Hash.sha3("challenge".getBytes()))); - assertThat(eip712Challenge.getMessageHash()) - .isEqualTo(messageHash) - .isEqualTo("0xffa80746e15229833c32e80aa3a3c161e0c5a0e47ff6fd68e713c8501a1456e5"); - String hash = HashUtils.concatenateAndHash( - "0x1901", - domainSeparator, - messageHash); - assertThat(eip712Challenge.getHash()) - .isEqualTo(hash) - .isEqualTo("0xea5ec041da81859f2c04a4876d5999ed8e66ad221b5b8699ca91f6814693a80e"); - } - - @Test - void shouldValidateDomainTypeParams() { - Challenge challenge = Challenge.builder().challenge("abcd").build(); - EIP712Domain domain = new EIP712Domain("OTHER DOMAIN", "2", 13L, null); - EIP712Challenge eip712Challenge = new EIP712Challenge(domain, challenge); - assertThat(eip712Challenge.getDomainTypeParams()) - .isEqualTo(List.of( - new TypeParam("name", "string"), - new TypeParam("version", "string"), - new TypeParam("chainId", "uint256"))); - String domainType = "EIP712Domain(string name,string version,uint256 chainId)"; - String domainSeparator = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(domainType.getBytes())), - Numeric.toHexString(Hash.sha3(domain.getName().getBytes())), - Numeric.toHexString(Hash.sha3(domain.getVersion().getBytes())), - Numeric.toHexString(Numeric.toBytesPadded(BigInteger.valueOf(domain.getChainId()), 32))); - assertThat(eip712Challenge.getDomain().getDomainSeparator()) - .isEqualTo(domainSeparator) - .isEqualTo("0x1ab64efc51b26dc09fa88c5377082acb34c14b43948c78d6a1472c0308a40aab"); - } - - @Test - void shouldValidateTypeParams() { - Challenge challenge = Challenge.builder().challenge("abcd").build(); - EIP712Domain domain = new EIP712Domain("OTHER DOMAIN", "2", 13L, null); - EIP712Challenge eip712Challenge = new EIP712Challenge(domain, challenge); - assertThat(eip712Challenge.getMessageTypeParams()) - .isEqualTo(List.of(new TypeParam("challenge", "string"))); - String messageType = "Challenge(string challenge)"; - String messageHash = HashUtils.concatenateAndHash( - Numeric.toHexString(Hash.sha3(messageType.getBytes())), - Numeric.toHexString(Hash.sha3("abcd".getBytes()))); - assertThat(eip712Challenge.getMessageHash()) - .isEqualTo(messageHash) - .isEqualTo("0x58c09e3e047920707563968aa3b3d1782e643869669d82283250c6ef75c8792f"); - } -} diff --git a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrderTest.java b/src/test/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrderTest.java deleted file mode 100644 index cf8ad6a6..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712DatasetOrderTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.order.DatasetOrder; -import com.iexec.commons.poco.utils.BytesUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.CipherException; -import org.web3j.crypto.ECKeyPair; -import org.web3j.crypto.WalletUtils; - -import java.io.IOException; -import java.math.BigInteger; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712DatasetOrderTest { - - private static final ObjectMapper mapper = new ObjectMapper(); - private static final EIP712Domain DOMAIN = new EIP712Domain(133, "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"); - private static final DatasetOrder DATASET_ORDER = DatasetOrder.builder() - .dataset("0x2550E5B60f48742aBce2275F34417e7cBf5AcA86") - .datasetprice(BigInteger.valueOf(0)) - .volume(BigInteger.valueOf(1000000)) - .tag("0x0000000000000000000000000000000000000000000000000000000000000001") - .apprestrict(BytesUtils.EMPTY_ADDRESS) - .workerpoolrestrict(BytesUtils.EMPTY_ADDRESS) - .requesterrestrict(BytesUtils.EMPTY_ADDRESS) - .salt("0xc49d07f99c47096900653b6ade4ccde4c52f773a5ad68f1da0a47c993cad4595") - .build(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - EIP712DatasetOrder eip712DatasetOrder = new EIP712DatasetOrder(DOMAIN, DATASET_ORDER); - String jsonString = mapper.writeValueAsString(eip712DatasetOrder); - EIP712DatasetOrder deserializedEip712DatasetOrder = mapper.readValue(jsonString, EIP712DatasetOrder.class); - assertThat(deserializedEip712DatasetOrder).usingRecursiveComparison().isEqualTo(eip712DatasetOrder); - } - - /** - * Expected signature string could also be found with: - *

- * iexec order sign --dataset --chain 133 \ - * --keystoredir /home/$USER/iexecdev/iexec-common/src/test/resources/ \ - * --wallet-file wallet.json --password whatever - *

- * Note: Don't forget to update salt - */ - @Test - void signDatasetOrderEIP712() { - EIP712DatasetOrder eip712DatasetOrder = new EIP712DatasetOrder(DOMAIN, DATASET_ORDER); - String signatureString = eip712DatasetOrder.signMessage(getWallet()); - assertThat(signatureString) - .isEqualTo("0x955db5242901dfec80d1cf20dce54a8c60274db55fb572ead03f32a2475e18b60e308e1a3bc599d774549283ec737bcedca8420bdae9e4784e3f62e8f4ff085f1c"); - } - - private ECKeyPair getWallet() { - try { - return WalletUtils.loadCredentials( - "whatever", - "./src/test/resources/wallet.json") - .getEcKeyPair(); - } catch (IOException | CipherException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrderTest.java b/src/test/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrderTest.java deleted file mode 100644 index 15891051..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712RequestOrderTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.order.RequestOrder; -import com.iexec.commons.poco.utils.BytesUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.CipherException; -import org.web3j.crypto.ECKeyPair; -import org.web3j.crypto.WalletUtils; - -import java.io.IOException; -import java.math.BigInteger; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712RequestOrderTest { - - private ObjectMapper mapper = new ObjectMapper(); - private static final EIP712Domain DOMAIN = new EIP712Domain(133, "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"); - - private static final RequestOrder REQUEST_ORDER = RequestOrder.builder() - .app("0x6709CAe77CDa2cbA8Cb90A4F5a4eFfb5c8Fe8367") - .appmaxprice(BigInteger.ZERO) - .dataset(BytesUtils.EMPTY_ADDRESS) - .datasetmaxprice(BigInteger.ZERO) - .workerpool("0x506fA5EaCa52B5d2F133452a45FFA68aD1CfB3C5") - .workerpoolmaxprice(BigInteger.ZERO) - .requester("0x1ec09e1782a43a770d54e813379c730e0b29ad4b") - .volume(BigInteger.ONE) - .tag(BytesUtils.toByte32HexString(0x1)) // any tag here - .category(BigInteger.ZERO) - .trust(BigInteger.ZERO) - .beneficiary(BytesUtils.EMPTY_ADDRESS) - .callback(BytesUtils.EMPTY_ADDRESS) - .params("{\"iexec_tee_post_compute_fingerprint\":\"76bfdee97e692b729e989694f3a566cf0e1de95fc456ff5ee88c75b1cb865e33|1eb627c1c94bbca03178b099b13fb4d1|13076027fc67accba753a3ed2edf03227dfd013b450d68833a5589ec44132100\",\"iexec_tee_post_compute_image\":\"iexechub/tee-worker-post-compute:1.0.0\",\"iexec_result_storage_provider\":\"ipfs\",\"iexec_result_storage_proxy\":\"https://result.viviani.iex.ec\",\"iexec_result_encryption\":false,\"iexec_input_files\":[],\"iexec_args\":\"Alice\"}") - .salt("0xee5c64cd59eaa084f59dbaa8f20b87260c4d6ac35c83214da657681bfe4e7632") - .build(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - EIP712RequestOrder eip712RequestOrder = new EIP712RequestOrder(DOMAIN, REQUEST_ORDER); - String jsonString = mapper.writeValueAsString(eip712RequestOrder); - EIP712RequestOrder deserializedEip712RequestOrder = mapper.readValue(jsonString, EIP712RequestOrder.class); - assertThat(deserializedEip712RequestOrder).usingRecursiveComparison().isEqualTo(eip712RequestOrder); - } - - /** - * Expected signature string could also be found with: - *

- * iexec order sign --request --chain 133 \ - * --keystoredir /home/$USER/iexecdev/iexec-common/src/test/resources/ \ - * --wallet-file wallet.json --password whatever - *

- * Note: Don't forget to update salt - */ - @Test - void signRequestOrderEIP712() { - EIP712RequestOrder eip712RequestOrder = new EIP712RequestOrder(DOMAIN, REQUEST_ORDER); - - String signatureString = eip712RequestOrder.signMessage(getWallet()); - assertThat(signatureString) - .isEqualTo("0xe4085c70e1d543daf0433d9b7a15f10679befb65dc33c3eeb284dee1ba409f724ce8223a262c8eeb2d3f4f3cc44c2c5d06192ab1d74b3554904425f6f5f8c4cc1c"); - } - - private ECKeyPair getWallet() { - try { - return WalletUtils.loadCredentials( - "whatever", - "./src/test/resources/wallet.json") - .getEcKeyPair(); - } catch (IOException | CipherException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrderTest.java b/src/test/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrderTest.java deleted file mode 100644 index 574f1de0..00000000 --- a/src/test/java/com/iexec/common/chain/eip712/entity/EIP712WorkerpoolOrderTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.chain.eip712.entity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iexec.commons.poco.eip712.EIP712Domain; -import com.iexec.commons.poco.order.WorkerpoolOrder; -import com.iexec.commons.poco.utils.BytesUtils; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.CipherException; -import org.web3j.crypto.ECKeyPair; -import org.web3j.crypto.WalletUtils; - -import java.io.IOException; -import java.math.BigInteger; - -import static org.assertj.core.api.Assertions.assertThat; - -class EIP712WorkerpoolOrderTest { - - private static final ObjectMapper mapper = new ObjectMapper(); - private static final EIP712Domain DOMAIN = new EIP712Domain(133, "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f"); - private static final WorkerpoolOrder WORKERPOOL_ORDER = WorkerpoolOrder.builder() - .workerpool("0x53Ef1328a96E40E125bca15b9a4da045C5e63E1A") - .workerpoolprice(BigInteger.ZERO) - .volume(BigInteger.ONE) - .category(BigInteger.ZERO) - .trust(BigInteger.ZERO) - .tag("0x0000000000000000000000000000000000000000000000000000000000000000") - .datasetrestrict(BytesUtils.EMPTY_ADDRESS) - .apprestrict(BytesUtils.EMPTY_ADDRESS) - .requesterrestrict(BytesUtils.EMPTY_ADDRESS) - .salt("0x40af1a4975ca6ca7285d7738e51c8da91a9daee4a23fb45d105068be56f85e56") - .build(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - EIP712WorkerpoolOrder eip712WorkerpoolOrder = new EIP712WorkerpoolOrder(DOMAIN, WORKERPOOL_ORDER); - String jsonString = mapper.writeValueAsString(eip712WorkerpoolOrder); - EIP712WorkerpoolOrder deserializedEip712WorkerPoolOrder = mapper.readValue(jsonString, EIP712WorkerpoolOrder.class); - assertThat(deserializedEip712WorkerPoolOrder).usingRecursiveComparison().isEqualTo(eip712WorkerpoolOrder); - } - - /** - * Expected signature string could also be found with: - *

- * iexec order sign --workerpool --chain 133 \ - * --keystoredir /home/$USER/iexecdev/iexec-common/src/test/resources/ \ - * --wallet-file wallet.json --password whatever - *

- * Note: Don't forget to update salt - */ - @Test - void signWorkerpoolOrderEIP712() { - EIP712WorkerpoolOrder eip712WorkerpoolOrder = new EIP712WorkerpoolOrder(DOMAIN, WORKERPOOL_ORDER); - String signatureString = eip712WorkerpoolOrder.signMessage(getWallet()); - assertThat(signatureString) - .isEqualTo("0x5d7c625e34c1dbfa76c6f1b953910f21d83fb51499748e2ccf15f9d357142f1c4f8b24dc583914b02c868d5a1d751409bbe83c753152cfd88fdd3ac65b39e9fe1c"); - } - - private ECKeyPair getWallet() { - try { - return WalletUtils.loadCredentials( - "whatever", - "./src/test/resources/wallet.json") - .getEcKeyPair(); - } catch (IOException | CipherException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/src/test/java/com/iexec/common/sdk/order/OrderSignerTests.java b/src/test/java/com/iexec/common/sdk/order/OrderSignerTests.java deleted file mode 100644 index 6ff34678..00000000 --- a/src/test/java/com/iexec/common/sdk/order/OrderSignerTests.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order; - -import com.iexec.commons.poco.order.AppOrder; -import com.iexec.commons.poco.order.DatasetOrder; -import com.iexec.commons.poco.order.RequestOrder; -import com.iexec.commons.poco.order.WorkerpoolOrder; -import lombok.SneakyThrows; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.ECKeyPair; -import org.web3j.crypto.Keys; - -import java.math.BigInteger; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -class OrderSignerTests { - - private OrderSigner orderSigner; - - @BeforeEach - @SneakyThrows - public void init() { - ECKeyPair ecKeyPair = Keys.createEcKeyPair(); - orderSigner = new OrderSigner(65535, "0x1", ecKeyPair); - } - - @Test - void shouldNotSignNullOrders() { - assertThat(orderSigner.signAppOrder(null)).isNull(); - assertThat(orderSigner.signDatasetOrder(null)).isNull(); - assertThat(orderSigner.signRequestOrder(null)).isNull(); - assertThat(orderSigner.signWorkerpoolOrder(null)).isNull(); - } - - @Test - void shouldNotSignEmptyOrders() { - AppOrder appOrder = AppOrder.builder().build(); - assertThatThrownBy(() -> orderSigner.signAppOrder(appOrder)) - .isInstanceOf(NullPointerException.class); - DatasetOrder datasetOrder = DatasetOrder.builder().build(); - assertThatThrownBy(() -> orderSigner.signDatasetOrder(datasetOrder)) - .isInstanceOf(NullPointerException.class); - RequestOrder requestOrder = RequestOrder.builder().build(); - assertThatThrownBy(() -> orderSigner.signRequestOrder(requestOrder)) - .isInstanceOf(NullPointerException.class); - WorkerpoolOrder workerpoolOrder = WorkerpoolOrder.builder().build(); - assertThatThrownBy(() -> orderSigner.signWorkerpoolOrder(workerpoolOrder)) - .isInstanceOf(NullPointerException.class); - } - - @Test - void shouldSignAppOrder() { - AppOrder appOrder = AppOrder - .builder() - .app("") - .appprice(BigInteger.TEN) - .volume(BigInteger.ONE) - .tag("") - .salt("") - .sign("") - .datasetrestrict("") - .requesterrestrict("") - .workerpoolrestrict("") - .build(); - assertThat(orderSigner.signAppOrder(appOrder)).isNotNull(); - } - - @Test - void shouldSignDatasetOrder() { - DatasetOrder datasetOrder = DatasetOrder - .builder() - .dataset("") - .datasetprice(BigInteger.TEN) - .volume(BigInteger.ONE) - .tag("") - .salt("") - .sign("") - .apprestrict("") - .requesterrestrict("") - .workerpoolrestrict("") - .build(); - assertThat(orderSigner.signDatasetOrder(datasetOrder)).isNotNull(); - } - - @Test - void shouldSignRequestOrder() { - RequestOrder requestOrder = RequestOrder - .builder() - .app("") - .appmaxprice(BigInteger.TEN) - .dataset("") - .datasetmaxprice(BigInteger.TEN) - .workerpool("") - .workerpoolmaxprice(BigInteger.TEN) - .requester("") - .volume(BigInteger.ONE) - .tag("") - .category(BigInteger.ZERO) - .trust(BigInteger.ONE) - .beneficiary("") - .callback("") - .params("") - .salt("") - .sign("") - .build(); - assertThat(orderSigner.signRequestOrder(requestOrder)).isNotNull(); - } - - @Test - void shouldSignWorkerpoolOrder() { - WorkerpoolOrder workerpoolOrder = WorkerpoolOrder - .builder() - .workerpool("") - .workerpoolprice(BigInteger.TEN) - .volume(BigInteger.ONE) - .tag("") - .trust(BigInteger.ONE) - .category(BigInteger.ZERO) - .salt("") - .sign("") - .apprestrict("") - .datasetrestrict("") - .requesterrestrict("") - .build(); - assertThat(orderSigner.signWorkerpoolOrder(workerpoolOrder)).isNotNull(); - } - -} diff --git a/src/test/java/com/iexec/common/sdk/order/payload/AppOrderTests.java b/src/test/java/com/iexec/common/sdk/order/payload/AppOrderTests.java deleted file mode 100644 index 4dce2ad1..00000000 --- a/src/test/java/com/iexec/common/sdk/order/payload/AppOrderTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -@Slf4j -class AppOrderTests { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - AppOrder appOrder = AppOrder.builder().build(); - String jsonString = mapper.writeValueAsString(appOrder); - assertThat(jsonString).isEqualTo("{\"volume\":null,\"tag\":null,\"salt\":null,\"sign\":null," + - "\"app\":null,\"appprice\":null,\"datasetrestrict\":\"\",\"workerpoolrestrict\":\"\",\"requesterrestrict\":\"\"}"); - AppOrder parsedAppOrder = mapper.readValue(jsonString, AppOrder.class); - assertThat(parsedAppOrder).usingRecursiveComparison().isEqualTo(appOrder); - } - -} diff --git a/src/test/java/com/iexec/common/sdk/order/payload/DatasetOrderTest.java b/src/test/java/com/iexec/common/sdk/order/payload/DatasetOrderTest.java deleted file mode 100644 index 010e527e..00000000 --- a/src/test/java/com/iexec/common/sdk/order/payload/DatasetOrderTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -class DatasetOrderTest { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - DatasetOrder datasetOrder = DatasetOrder.builder().build(); - String jsonString = mapper.writeValueAsString(datasetOrder); - assertThat(jsonString).isEqualTo("{\"volume\":null,\"tag\":null,\"salt\":null,\"sign\":null," + - "\"dataset\":null,\"datasetprice\":null,\"apprestrict\":\"\",\"workerpoolrestrict\":\"\",\"requesterrestrict\":\"\"}"); - DatasetOrder parsedDatasetOrder = mapper.readValue(jsonString, DatasetOrder.class); - assertThat(parsedDatasetOrder).usingRecursiveComparison().isEqualTo(datasetOrder); - } - -} \ No newline at end of file diff --git a/src/test/java/com/iexec/common/sdk/order/payload/RequestOrderTest.java b/src/test/java/com/iexec/common/sdk/order/payload/RequestOrderTest.java deleted file mode 100644 index 862207a0..00000000 --- a/src/test/java/com/iexec/common/sdk/order/payload/RequestOrderTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -class RequestOrderTest { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - RequestOrder requestOrder = RequestOrder.builder().build(); - String jsonString = mapper.writeValueAsString(requestOrder); - assertThat(jsonString).isEqualTo("{\"volume\":null,\"tag\":null,\"salt\":null,\"sign\":null," + - "\"app\":\"\",\"appmaxprice\":null,\"dataset\":\"\",\"datasetmaxprice\":null,\"workerpool\":\"\",\"workerpoolmaxprice\":null," + - "\"requester\":\"\",\"category\":null,\"trust\":null,\"beneficiary\":\"\",\"callback\":\"\",\"params\":null}"); - RequestOrder parsedRequestOrder = mapper.readValue(jsonString, RequestOrder.class); - assertThat(parsedRequestOrder).usingRecursiveComparison().isEqualTo(requestOrder); - } - -} diff --git a/src/test/java/com/iexec/common/sdk/order/payload/WorkerpoolOrderTests.java b/src/test/java/com/iexec/common/sdk/order/payload/WorkerpoolOrderTests.java deleted file mode 100644 index 6324adaa..00000000 --- a/src/test/java/com/iexec/common/sdk/order/payload/WorkerpoolOrderTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 IEXEC BLOCKCHAIN TECH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.iexec.common.sdk.order.payload; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -class WorkerpoolOrderTests { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @Test - void shouldSerializeAndDeserialize() throws JsonProcessingException { - WorkerpoolOrder workerpoolOrder = WorkerpoolOrder.builder().build(); - String jsonString = mapper.writeValueAsString(workerpoolOrder); - assertThat(jsonString).isEqualTo("{\"volume\":null,\"tag\":null,\"salt\":null,\"sign\":null," + - "\"workerpool\":null,\"workerpoolprice\":null,\"trust\":null,\"category\":null,\"apprestrict\":\"\",\"datasetrestrict\":\"\",\"requesterrestrict\":\"\"}"); - WorkerpoolOrder parsedWorkerpoolOrder = mapper.readValue(jsonString, WorkerpoolOrder.class); - assertThat(parsedWorkerpoolOrder).usingRecursiveComparison().isEqualTo(workerpoolOrder); - } - -}