Skip to content

Commit

Permalink
fix: Addressing review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Kristiyan Selveliev <[email protected]>
  • Loading branch information
kselveliev committed Feb 6, 2025
1 parent 7749869 commit 2b71dd1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private Map<Bytes, Bytes> getStorageUpdates(Address accountAddress) {
Set<SlotKey> modifiedKeys = states.get(STORAGE_KEY).modifiedKeys().stream()
.filter(SlotKey.class::isInstance)
.map(SlotKey.class::cast)
.filter(slotKey -> slotKey.hasContractID() && slotKey.contractID() != null)
.filter(SlotKey::hasContractID)
.collect(Collectors.toSet());

if (modifiedKeys.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,33 +573,6 @@ void shouldSkipSlotKeyWhenHasContractIDIsFalse() {
assertThat(opcode.storage()).isEmpty();
}

@Test
@DisplayName(
"given storage is enabled in tracer options, should skip slotKey when contractID is null for modularized services")
void shouldSkipSlotKeyWhenContractIDIsNull() {
// Given
tracerOptions = tracerOptions.toBuilder().storage(true).build();
when(mirrorNodeEvmProperties.isModularizedServices()).thenReturn(true);
frame = setupInitialFrame(tracerOptions);

MapWritableStates mockStates = mock(MapWritableStates.class);
when(mirrorNodeState.getWritableStates(CONTRACT_SERVICE)).thenReturn(mockStates);
WritableKVState<SlotKey, SlotValue> mockStorageState = mock(WritableKVState.class);
doReturn(mockStorageState).when(mockStates).get(STORAGE_KEY);

SlotKey slotKeyWithNullContractID = mock(SlotKey.class);
when(slotKeyWithNullContractID.hasContractID()).thenReturn(true);
when(slotKeyWithNullContractID.contractID()).thenReturn(null);

when(mockStorageState.modifiedKeys()).thenReturn(Set.of(slotKeyWithNullContractID));

// When
final Opcode opcode = executeOperation(frame);

// Then
assertThat(opcode.storage()).isEmpty();
}

@Test
@DisplayName(
"given storage is enabled in tracer options, should skip slotKey when contract address does not match for modularized services")
Expand Down

0 comments on commit 2b71dd1

Please sign in to comment.