Skip to content

Commit

Permalink
Applying suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarev committed Dec 4, 2024
1 parent fb102a8 commit e430789
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class MCopyBoundTest {
public class MCopyInputTest {

private ActivationConfig.ForBlock activationConfig;

Expand All @@ -52,7 +52,7 @@ void setup() {
}

@ParameterizedTest
@MethodSource("provideParametersForMCOPYBoundTest")
@MethodSource("provideParametersForOOGCases")
void testMCopy_ShouldThrowOOGException(String[] initMemory, int dst, int src, long length) {
// Given
byte[] code = compiler.compile("MCOPY");
Expand All @@ -71,24 +71,26 @@ void testMCopy_ShouldThrowOOGException(String[] initMemory, int dst, int src, lo
program.stackPush(DataWord.valueOf(dst));

// Then
try {
while (!program.isStopped()) {
vm.step(program);
}
Assertions.fail("OutOfGasException should be thrown!");
} catch(Program.StackTooSmallException e) {
Assertions.fail("Stack too small exception");
} catch(Program.OutOfGasException e) {
Assertions.assertTrue(e.getMessage().contains("Not enough gas for 'MCOPY' operation"));
}
Program.OutOfGasException ex = Assertions.assertThrows(Program.OutOfGasException.class, () -> executeProgram(vm, program));
Assertions.assertTrue(ex.getMessage().contains("Not enough gas for 'MCOPY' operation"));
}

private static Stream<Arguments> provideParametersForMCOPYBoundTest() {
private static Stream<Arguments> provideParametersForOOGCases() {
return Stream.of(
Arguments.of(new String[]{ "0000000000000000000000000000000000000000000000000000000000000000" }, 0, 0, -1),
Arguments.of(new String[]{}, 0, 0, -(2 * (Long.MAX_VALUE / 3))),
Arguments.of(new String[]{}, 0, 0, Integer.MAX_VALUE + 1L)
);
}

private static void executeProgram(VM vm, Program program) {
try {
while (!program.isStopped()) {
vm.step(program);
}
} catch(Program.StackTooSmallException e) {
Assertions.fail("Stack too small exception");
}
}

}

0 comments on commit e430789

Please sign in to comment.