Skip to content

Commit

Permalink
getStorageAt from empty cell now returns 0x0
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Apr 7, 2021
1 parent dc17c4e commit 9b36a73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/org/ethereum/rpc/Web3Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public String eth_getStorageAt(String address, String storageIdx, String blockId
.getStorageValue(addr, DataWord.valueOf(stringHexToByteArray(storageIdx)));

if (sv == null) {
s = null;
s = "0x0";
} else {
s = toUnformattedJsonHex(sv.getData());
}
Expand Down
19 changes: 19 additions & 0 deletions rskj-core/src/test/java/org/ethereum/rpc/Web3ImplUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ public void eth_getStorageAt() {
result);
}


@Test
public void eth_getStorageAtEmptyCell() {
String id = "id";
String addr = "0x0011223344556677880011223344556677889900";
RskAddress expectedAddress = new RskAddress(addr);
String storageIdx = "0x01";
DataWord expectedIdx = DataWord.valueOf(stringHexToByteArray(storageIdx));

AccountInformationProvider aip = mock(AccountInformationProvider.class);
when(retriever.getInformationProvider(eq(id))).thenReturn(aip);
when(aip.getStorageValue(eq(expectedAddress), eq(expectedIdx)))
.thenReturn(null);

String result = target.eth_getStorageAt(addr, storageIdx, id);
assertEquals("0x0",
result);
}

@Test
public void eth_getBlockTransactionCountByNumber_blockNotFound() {
String id = "id";
Expand Down

0 comments on commit 9b36a73

Please # to comment.