use of co.rsk.core.bc.AccountInformationProvider in project rskj by rsksmart.
the class Web3ImplUnitTest method eth_getBalance.
@Test
public void eth_getBalance() {
String id = "id";
String addr = "0x0011223344556677880011223344556677889900";
RskAddress expectedAddress = new RskAddress(addr);
AccountInformationProvider aip = mock(AccountInformationProvider.class);
when(retriever.getInformationProvider(eq(id))).thenReturn(aip);
when(aip.getBalance(eq(expectedAddress))).thenReturn(new Coin(BigInteger.ONE));
String result = target.eth_getBalance(addr, id);
assertEquals("0x1", result);
}
use of co.rsk.core.bc.AccountInformationProvider in project rskj by rsksmart.
the class Web3ImplUnitTest method eth_getStorageAt.
@Test
public void eth_getStorageAt() {
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(DataWord.ONE);
String result = target.eth_getStorageAt(addr, storageIdx, id);
assertEquals("0x0000000000000000000000000000000000000000000000000000000000000001", result);
}
use of co.rsk.core.bc.AccountInformationProvider in project rskj by rsksmart.
the class Web3ImplUnitTest method eth_getStorageAtEmptyCell.
@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);
}
use of co.rsk.core.bc.AccountInformationProvider in project rskj by rsksmart.
the class Web3InformationRetrieverTest method getState_latest.
@Test
public void getState_latest() {
Block block = mock(Block.class);
BlockHeader header = mock(BlockHeader.class);
when(block.getHeader()).thenReturn(header);
when(blockchain.getBestBlock()).thenReturn(block);
RepositorySnapshot snapshot = mock(RepositorySnapshot.class);
when(locator.findSnapshotAt(eq(header))).thenReturn(Optional.of(snapshot));
AccountInformationProvider result = target.getInformationProvider("latest");
assertEquals(snapshot, result);
}
use of co.rsk.core.bc.AccountInformationProvider in project rskj by rsksmart.
the class Web3InformationRetrieverTest method getState_pending.
@Test
public void getState_pending() {
PendingState aip = mock(PendingState.class);
when(txPool.getPendingState()).thenReturn(aip);
AccountInformationProvider result = target.getInformationProvider("pending");
assertEquals(aip, result);
}
Aggregations