Search in sources :

Example 1 with NewBlockHashesMessage

use of org.ethereum.net.eth.message.NewBlockHashesMessage in project rskj by rsksmart.

the class NewBlockHashesMessageTest method test_1.

@Test
public /* NewBlockHashesMessage 1 from new */
void test_1() {
    List<BlockIdentifier> identifiers = Arrays.asList(new BlockIdentifier(decode("4ee6424d776b3f59affc20bc2de59e67f36e22cc07897ff8df152242c921716b"), 1), new BlockIdentifier(decode("7d2fe4df0dbbc9011da2b3bf177f0c6b7e71a11c509035c5d751efa5cf9b4817"), 2));
    NewBlockHashesMessage newBlockHashesMessage = new NewBlockHashesMessage(identifiers);
    System.out.println(newBlockHashesMessage);
    String expected = "f846e2a04ee6424d776b3f59affc20bc2de59e67f36e22cc07897ff8df152242c921716b01e2a07d2fe4df0dbbc9011da2b3bf177f0c6b7e71a11c509035c5d751efa5cf9b481702";
    assertEquals(expected, toHexString(newBlockHashesMessage.getEncoded()));
    assertEquals(EthMessageCodes.NEW_BLOCK_HASHES, newBlockHashesMessage.getCommand());
    assertEquals(2, newBlockHashesMessage.getBlockIdentifiers().size());
    assertEquals(null, newBlockHashesMessage.getAnswerMessage());
}
Also used : BlockIdentifier(org.ethereum.core.BlockIdentifier) Hex.toHexString(org.spongycastle.util.encoders.Hex.toHexString) NewBlockHashesMessage(org.ethereum.net.eth.message.NewBlockHashesMessage) Test(org.junit.Test)

Aggregations

BlockIdentifier (org.ethereum.core.BlockIdentifier)1 NewBlockHashesMessage (org.ethereum.net.eth.message.NewBlockHashesMessage)1 Test (org.junit.Test)1 Hex.toHexString (org.spongycastle.util.encoders.Hex.toHexString)1