mirror of https://github.com/hyperledger/besu
Migrate referenceTests to Junit5 (#3850)
* Remove deprecated cleanup task * Move util class into test-support This is because this class can be used outside the scope of the junit tests but it'll not be part of main * Move referenceTests into its own scope * Migrate referenceTests to Junit5 I inlined `o.h.b.e.vm.AbstractRetryingTest` into `o.h.b.e.vm.VMReferenceTest` because there was a single usage of the abstraction and also because it wasn't portable to how Junit5 parameters work Signed-off-by: Diego López León <dieguitoll@gmail.com> Co-authored-by: Danno Ferrin <danno.ferrin@gmail.com> Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>pull/3934/head
parent
5b55c0a34e
commit
02d389a19e
@ -0,0 +1,51 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* 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.ethereum.rlp; |
||||
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue; |
||||
|
||||
import org.assertj.core.api.Assertions; |
||||
import org.hyperledger.besu.ethereum.rlp.util.RLPTestUtil; |
||||
import org.hyperledger.besu.testutil.JsonTestParameters; |
||||
|
||||
import java.util.stream.Stream; |
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest; |
||||
import org.junit.jupiter.params.provider.Arguments; |
||||
import org.junit.jupiter.params.provider.MethodSource; |
||||
|
||||
/** The Ethereum reference RLP tests. */ |
||||
public class RLPRefTest { |
||||
|
||||
private static final String TEST_CONFIG_FILES = "RLPTests/rlptest.json"; |
||||
|
||||
public static Stream<Arguments> getTestParametersForConfig() { |
||||
return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES).stream().map(params -> Arguments.of(params[0], params[1], params[2])); |
||||
} |
||||
|
||||
@ParameterizedTest(name = "Name: {0}") |
||||
@MethodSource("getTestParametersForConfig") |
||||
public void encode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { |
||||
assumeTrue(runTest, "Test was blacklisted"); |
||||
Assertions.assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut()); |
||||
} |
||||
|
||||
@ParameterizedTest(name = "Name: {0}") |
||||
@MethodSource("getTestParametersForConfig") |
||||
public void decode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { |
||||
assumeTrue(runTest, "Test was blacklisted"); |
||||
Assertions.assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn()); |
||||
} |
||||
} |
0
ethereum/core/src/test/resources/regressions/generalstate/ripeMdAccountShouldBeDeletedWhenEmptyAndTouchedTransactionSucceedsPostEIP158.json → ethereum/referencetests/src/reference-test/resources/regressions/generalstate/ripeMdAccountShouldBeDeletedWhenEmptyAndTouchedTransactionSucceedsPostEIP158.json
0
ethereum/core/src/test/resources/regressions/generalstate/ripeMdAccountShouldBeDeletedWhenEmptyAndTouchedTransactionSucceedsPostEIP158.json → ethereum/referencetests/src/reference-test/resources/regressions/generalstate/ripeMdAccountShouldBeDeletedWhenEmptyAndTouchedTransactionSucceedsPostEIP158.json
@ -1,57 +0,0 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* 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.ethereum.rlp; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.junit.Assume.assumeTrue; |
||||
|
||||
import org.hyperledger.besu.ethereum.rlp.util.RLPTestUtil; |
||||
import org.hyperledger.besu.testutil.JsonTestParameters; |
||||
|
||||
import java.util.Collection; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.junit.runners.Parameterized; |
||||
import org.junit.runners.Parameterized.Parameters; |
||||
|
||||
/** The Ethereum reference RLP tests. */ |
||||
@RunWith(Parameterized.class) |
||||
public class RLPRefTest { |
||||
|
||||
private static final String TEST_CONFIG_FILES = "RLPTests/rlptest.json"; |
||||
|
||||
private final RLPRefTestCaseSpec spec; |
||||
|
||||
public RLPRefTest(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { |
||||
this.spec = spec; |
||||
assumeTrue("Test was blacklisted", runTest); |
||||
} |
||||
|
||||
@Parameters(name = "Name: {0}") |
||||
public static Collection<Object[]> getTestParametersForConfig() { |
||||
return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES); |
||||
} |
||||
|
||||
@Test |
||||
public void encode() { |
||||
assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut()); |
||||
} |
||||
|
||||
@Test |
||||
public void decode() { |
||||
assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn()); |
||||
} |
||||
} |
Loading…
Reference in new issue