Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ site/
jitpack.yml
/ethereum/eth/src/test/resources/tx.csv.gz
**/**/.factorypath
.jqwik-database
4 changes: 4 additions & 0 deletions acceptance-tests/tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ task acceptanceTest(type: Test) {
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
exclude '**/bftsoak/**'

// Enable JUnit 5 extension auto-detection to initialize SignatureAlgorithmFactory early
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
useJUnitPlatform {}

dependsOn(rootProject.installDist)
Expand Down Expand Up @@ -128,6 +130,8 @@ task acceptanceTestBftSoak(type: Test) {
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
include '**/bftsoak/**'

// Enable JUnit 5 extension auto-detection to initialize SignatureAlgorithmFactory early
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
useJUnitPlatform {}

dependsOn(rootProject.installDist)
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ configure(allprojects - project(':platform')) {
systemProperty name, System.getProperty(name)
}
}
// Enable JUnit 5 extension auto-detection to initialize SignatureAlgorithmFactory early
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
useJUnitPlatform {}
finalizedBy jacocoTestReport // report is always generated after tests run
}
Expand Down Expand Up @@ -536,6 +538,8 @@ subprojects {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
// Enable JUnit 5 extension auto-detection to initialize SignatureAlgorithmFactory early
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
useJUnitPlatform {}
}
}
Expand Down
2 changes: 2 additions & 0 deletions ethereum/referencetests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ dependencies {
}

tasks.register('referenceTests', Test) {
// Enable JUnit 5 extension auto-detection to initialize SignatureAlgorithmFactory early
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
useJUnitPlatform()
doFirst {
if (!file("src/reference-test/external-resources/README.md").exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
Expand Down Expand Up @@ -46,10 +45,6 @@
*/
public class ReferenceTestProtocolSchedules {

static {
SignatureAlgorithmFactory.setDefaultInstance();
}

private static final BigInteger CHAIN_ID = BigInteger.ONE;

private static final List<String> SPECS_PRIOR_TO_DELETING_EMPTY_ACCOUNTS =
Expand Down
1 change: 1 addition & 0 deletions testutil/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sonarqube {
}

dependencies {
implementation project(':crypto:algorithms')
implementation project(':ethereum:eth')
implementation project(':plugin-api')
implementation project(':util')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright contributors to Besu.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.testutil;

import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;

import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* JUnit 5 extension that ensures SignatureAlgorithmFactory is initialized early in the test
* lifecycle. This improves test performance by avoiding repeated initialization when
* ProtocolScheduleBuilder creates schedules for multiple forks.
*
* <p>This extension is automatically registered via junit-platform.properties when auto-detection
* is enabled.
*/
public class SignatureAlgorithmInitExtension implements BeforeAllCallback {
private static volatile boolean initialized = false;

/** Instantiates a new Signature algorithm init extension. */
public SignatureAlgorithmInitExtension() {}

@Override
public void beforeAll(final ExtensionContext context) {
if (!initialized) {
synchronized (SignatureAlgorithmInitExtension.class) {
if (!initialized) {
SignatureAlgorithmFactory.setDefaultInstance();
initialized = true;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.hyperledger.besu.testutil.SignatureAlgorithmInitExtension
Loading