Search in sources :

Example 1 with LogFilterElement

use of org.ethereum.rpc.LogFilterElement in project rskj by rsksmart.

the class Web3RskImplTest method web3_LogFilterElement_toString.

@Test
public void web3_LogFilterElement_toString() {
    LogInfo logInfo = Mockito.mock(LogInfo.class);
    byte[] valueToTest = HashUtil.keccak256(new byte[] { 1 });
    Mockito.when(logInfo.getData()).thenReturn(valueToTest);
    List<DataWord> topics = new ArrayList<>();
    topics.add(new DataWord("c1"));
    topics.add(new DataWord("c2"));
    Mockito.when(logInfo.getTopics()).thenReturn(topics);
    Block block = Mockito.mock(Block.class);
    Mockito.when(block.getHash()).thenReturn(new Keccak256(valueToTest));
    Mockito.when(block.getNumber()).thenReturn(1L);
    int txIndex = 1;
    Transaction tx = Mockito.mock(Transaction.class);
    byte[] bytes = new byte[32];
    bytes[0] = 2;
    Mockito.when(tx.getHash()).thenReturn(new Keccak256(bytes));
    int logIdx = 5;
    LogFilterElement logFilterElement = new LogFilterElement(logInfo, block, txIndex, tx, logIdx);
    Assert.assertEquals(logFilterElement.toString(), "LogFilterElement{logIndex='0x5', blockNumber='0x1', blockHash='0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2', transactionHash='0x0200000000000000000000000000000000000000000000000000000000000000', transactionIndex='0x1', address='0x00', data='0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2', topics=[0x00000000000000000000000000000000000000000000000000000000000000c1, 0x00000000000000000000000000000000000000000000000000000000000000c2]}");
}
Also used : LogFilterElement(org.ethereum.rpc.LogFilterElement) LogInfo(org.ethereum.vm.LogInfo) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList) Block(org.ethereum.core.Block) DataWord(org.ethereum.vm.DataWord) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Example 2 with LogFilterElement

use of org.ethereum.rpc.LogFilterElement in project rskj by rsksmart.

the class Web3RskImplTest method web3_LogFilterElementNullData_toString.

@Test
public void web3_LogFilterElementNullData_toString() {
    LogInfo logInfo = mock(LogInfo.class);
    byte[] valueToTest = HashUtil.keccak256(new byte[] { 1 });
    Mockito.when(logInfo.getData()).thenReturn(null);
    List<DataWord> topics = new ArrayList<>();
    topics.add(DataWord.valueFromHex("c1"));
    topics.add(DataWord.valueFromHex("c2"));
    Mockito.when(logInfo.getTopics()).thenReturn(topics);
    Block block = mock(Block.class);
    Mockito.when(block.getHash()).thenReturn(new Keccak256(valueToTest));
    Mockito.when(block.getNumber()).thenReturn(1L);
    int txIndex = 1;
    Transaction tx = mock(Transaction.class);
    byte[] bytes = new byte[32];
    bytes[0] = 2;
    Mockito.when(tx.getHash()).thenReturn(new Keccak256(bytes));
    int logIdx = 5;
    LogFilterElement logFilterElement = new LogFilterElement(logInfo, block, txIndex, tx, logIdx);
    assertEquals("LogFilterElement{logIndex='0x5', blockNumber='0x1', blockHash='0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2', transactionHash='0x0200000000000000000000000000000000000000000000000000000000000000', transactionIndex='0x1', address='0x', data='0x', topics=[0x00000000000000000000000000000000000000000000000000000000000000c1, 0x00000000000000000000000000000000000000000000000000000000000000c2]}", logFilterElement.toString());
}
Also used : LogFilterElement(org.ethereum.rpc.LogFilterElement) LogInfo(org.ethereum.vm.LogInfo) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList) Block(org.ethereum.core.Block) DataWord(org.ethereum.vm.DataWord) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Example 3 with LogFilterElement

use of org.ethereum.rpc.LogFilterElement in project rskj by rsksmart.

the class Web3RskImplTest method web3_LogFilterElementNullAddress_toString.

@Test
public void web3_LogFilterElementNullAddress_toString() {
    LogInfo logInfo = mock(LogInfo.class);
    byte[] valueToTest = HashUtil.keccak256(new byte[] { 1 });
    Mockito.when(logInfo.getData()).thenReturn(valueToTest);
    List<DataWord> topics = new ArrayList<>();
    topics.add(DataWord.valueFromHex("c1"));
    topics.add(DataWord.valueFromHex("c2"));
    Mockito.when(logInfo.getTopics()).thenReturn(topics);
    Block block = mock(Block.class);
    Mockito.when(block.getHash()).thenReturn(new Keccak256(valueToTest));
    Mockito.when(block.getNumber()).thenReturn(1L);
    int txIndex = 1;
    Transaction tx = mock(Transaction.class);
    byte[] bytes = new byte[32];
    bytes[0] = 2;
    Mockito.when(tx.getHash()).thenReturn(new Keccak256(bytes));
    int logIdx = 5;
    LogFilterElement logFilterElement = new LogFilterElement(logInfo, block, txIndex, tx, logIdx);
    assertEquals("LogFilterElement{logIndex='0x5', blockNumber='0x1', blockHash='0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2', transactionHash='0x0200000000000000000000000000000000000000000000000000000000000000', transactionIndex='0x1', address='0x', data='0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2', topics=[0x00000000000000000000000000000000000000000000000000000000000000c1, 0x00000000000000000000000000000000000000000000000000000000000000c2]}", logFilterElement.toString());
}
Also used : LogFilterElement(org.ethereum.rpc.LogFilterElement) LogInfo(org.ethereum.vm.LogInfo) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList) Block(org.ethereum.core.Block) DataWord(org.ethereum.vm.DataWord) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Aggregations

Keccak256 (co.rsk.crypto.Keccak256)3 ArrayList (java.util.ArrayList)3 Block (org.ethereum.core.Block)3 Transaction (org.ethereum.core.Transaction)3 LogFilterElement (org.ethereum.rpc.LogFilterElement)3 DataWord (org.ethereum.vm.DataWord)3 LogInfo (org.ethereum.vm.LogInfo)3 Test (org.junit.Test)3