From e640b716c0ccd2ccae97fa908127e3dba63ab54a Mon Sep 17 00:00:00 2001 From: Nazaret Garcia Date: Thu, 26 Sep 2024 23:34:36 -0300 Subject: [PATCH] Applying suggestions --- .../java/co/rsk/vm/opcode/MCopyDslTest.java | 29 +++++-------------- ...stCopying32BytesFromOffset32toOffset0.txt} | 0 ...Test.txt => testRSKIPNotActivatedTest.txt} | 0 3 files changed, 8 insertions(+), 21 deletions(-) rename rskj-core/src/test/resources/dsl/opcode/mcopy/{mCopyTestCase1.txt => testCopying32BytesFromOffset32toOffset0.txt} (100%) rename rskj-core/src/test/resources/dsl/opcode/mcopy/{mCopyNotActivatedTest.txt => testRSKIPNotActivatedTest.txt} (100%) diff --git a/rskj-core/src/test/java/co/rsk/vm/opcode/MCopyDslTest.java b/rskj-core/src/test/java/co/rsk/vm/opcode/MCopyDslTest.java index b2c10c516d3..5c2b5106d20 100644 --- a/rskj-core/src/test/java/co/rsk/vm/opcode/MCopyDslTest.java +++ b/rskj-core/src/test/java/co/rsk/vm/opcode/MCopyDslTest.java @@ -5,8 +5,7 @@ import co.rsk.test.dsl.DslParser; import co.rsk.test.dsl.DslProcessorException; import co.rsk.test.dsl.WorldDslProcessor; -import org.ethereum.config.blockchain.upgrades.ActivationConfig; -import org.ethereum.config.blockchain.upgrades.ConsensusRule; +import com.typesafe.config.ConfigValueFactory; import org.ethereum.core.Block; import org.ethereum.core.Transaction; import org.ethereum.core.TransactionReceipt; @@ -16,31 +15,21 @@ import java.io.FileNotFoundException; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; -import static org.mockito.Mockito.atLeast; - public class MCopyDslTest { @Test void testMCOPY_whenNotActivated_behavesAsExpected() throws FileNotFoundException, DslProcessorException { - // Config Spies Setup - - TestSystemProperties config = new TestSystemProperties(); - ActivationConfig activationConfig = config.getActivationConfig(); + // Test Config Setup - TestSystemProperties configSpy = spy(config); - ActivationConfig activationConfigSpy = spy(activationConfig); - - doReturn(activationConfigSpy).when(configSpy).getActivationConfig(); - doReturn(false).when(activationConfigSpy).isActive(eq(ConsensusRule.RSKIP445), anyLong()); + TestSystemProperties configWithRskip445Disabled = new TestSystemProperties(rawConfig -> + rawConfig.withValue("blockchain.config.hardforkActivationHeights.lovell700", ConfigValueFactory.fromAnyRef(-1)) + ); // Test Setup - DslParser parser = DslParser.fromResource("dsl/opcode/mcopy/mCopyNotActivatedTest.txt"); - World world = new World(configSpy); + DslParser parser = DslParser.fromResource("dsl/opcode/mcopy/testRSKIPNotActivatedTest.txt"); + World world = new World(configWithRskip445Disabled); WorldDslProcessor processor = new WorldDslProcessor(world); processor.processCommands(parser); @@ -65,8 +54,6 @@ void testMCOPY_whenNotActivated_behavesAsExpected() throws FileNotFoundException Assertions.assertEquals(1, creationStatus.length); Assertions.assertEquals(1, creationStatus[0]); - verify(activationConfigSpy, atLeast(1)).isActive(eq(ConsensusRule.RSKIP445), eq(2L)); - // There's one block (b02) containing only 1 transaction Block block2 = world.getBlockByName("b02"); Assertions.assertNotNull(block2); @@ -90,7 +77,7 @@ void testMCOPY_whenNotActivated_behavesAsExpected() throws FileNotFoundException @Test void testMCOPY_testCase1_behavesAsExpected() throws FileNotFoundException, DslProcessorException { - DslParser parser = DslParser.fromResource("dsl/opcode/mcopy/mCopyTestCase1.txt"); + DslParser parser = DslParser.fromResource("dsl/opcode/mcopy/testCopying32BytesFromOffset32toOffset0.txt"); World world = new World(); WorldDslProcessor processor = new WorldDslProcessor(world); processor.processCommands(parser); diff --git a/rskj-core/src/test/resources/dsl/opcode/mcopy/mCopyTestCase1.txt b/rskj-core/src/test/resources/dsl/opcode/mcopy/testCopying32BytesFromOffset32toOffset0.txt similarity index 100% rename from rskj-core/src/test/resources/dsl/opcode/mcopy/mCopyTestCase1.txt rename to rskj-core/src/test/resources/dsl/opcode/mcopy/testCopying32BytesFromOffset32toOffset0.txt diff --git a/rskj-core/src/test/resources/dsl/opcode/mcopy/mCopyNotActivatedTest.txt b/rskj-core/src/test/resources/dsl/opcode/mcopy/testRSKIPNotActivatedTest.txt similarity index 100% rename from rskj-core/src/test/resources/dsl/opcode/mcopy/mCopyNotActivatedTest.txt rename to rskj-core/src/test/resources/dsl/opcode/mcopy/testRSKIPNotActivatedTest.txt