From 42e58089ec970cc69157c6736d013d9627f836d9 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 12 Dec 2023 07:29:22 +1000 Subject: [PATCH 1/3] update crypto tests to junit5 Signed-off-by: Sally MacFarlane --- crypto/services/build.gradle | 1 - .../cryptoservices/KeyPairSecurityModuleTest.java | 12 ++++++------ .../hyperledger/besu/cryptoservices/NodeKeyTest.java | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/crypto/services/build.gradle b/crypto/services/build.gradle index f6e082836c0..e90585a0b2a 100644 --- a/crypto/services/build.gradle +++ b/crypto/services/build.gradle @@ -32,7 +32,6 @@ dependencies { api project(':crypto:algorithms') api project(':plugin-api') - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' diff --git a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java index 68d369ae538..79151a55cdc 100644 --- a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java +++ b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java @@ -22,22 +22,22 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.spec.ECPoint; import org.apache.tuweni.bytes.Bytes; import org.assertj.core.api.Assertions; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class KeyPairSecurityModuleTest { - @Rule public final TemporaryFolder temp = new TemporaryFolder(); + @TempDir public Path temp; @Test public void validatePublicKeyFromECPointCanBeConstructed() throws IOException { - final File keyDirectory = temp.newFolder(); - final File keyFile = new File(keyDirectory, "key"); + final File keyFile = Files.createFile(temp.resolve("key")).toFile(); final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile); diff --git a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java index 07008f06cbc..261271aee9b 100644 --- a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java +++ b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java @@ -21,12 +21,12 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeKeyTest { - @Before + @BeforeEach public void resetInstance() { SignatureAlgorithmFactory.resetInstance(); } From 1f33168ac7ca3baabc38402ed0dbd4ac7cdc619c Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 12 Dec 2023 07:33:41 +1000 Subject: [PATCH 2/3] fixed temp file Signed-off-by: Sally MacFarlane --- .../besu/cryptoservices/KeyPairSecurityModuleTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java index 79151a55cdc..fac403e041d 100644 --- a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java +++ b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java @@ -20,9 +20,7 @@ import org.hyperledger.besu.crypto.SECPPublicKey; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; -import java.io.File; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.security.spec.ECPoint; @@ -33,13 +31,11 @@ public class KeyPairSecurityModuleTest { - @TempDir public Path temp; + @TempDir public Path keyFile; @Test public void validatePublicKeyFromECPointCanBeConstructed() throws IOException { - final File keyFile = Files.createFile(temp.resolve("key")).toFile(); - - final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile); + final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile.resolve("key")); final KeyPairSecurityModule keyPairSecurityModule = new KeyPairSecurityModule(keyPair); final ECPoint ecPoint = keyPairSecurityModule.getPublicKey().getW(); From 3721eeb50b8e36f4399dfa00bacee90a3b1319e7 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 12 Dec 2023 08:51:15 +1000 Subject: [PATCH 3/3] removed vintage junit dep Signed-off-by: Sally MacFarlane --- crypto/services/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/crypto/services/build.gradle b/crypto/services/build.gradle index e90585a0b2a..53b46d57473 100644 --- a/crypto/services/build.gradle +++ b/crypto/services/build.gradle @@ -34,8 +34,6 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } artifacts { testSupportArtifacts testSupportJar }