use of neo.model.network.GetBlocksPayload in project neo-java by coranos.
the class TestPayload method test005GetBlocksPayloadGenesisToGenesis.
/**
* tests the GetBlocksPayload getting the genesis block.
*/
@Test
public void test005GetBlocksPayloadGenesisToGenesis() {
final GetBlocksPayload payload = new GetBlocksPayload(GenesisBlockUtil.GENESIS_HASH, GenesisBlockUtil.GENESIS_HASH);
final String expectedStr = new JSONObject(TestUtil.getJsonTestResourceAsString(TEST_PACKAGE, getClass().getSimpleName(), "test005GetBlocksPayloadGenesisToGenesis")).toString();
final String actualStr = payload.toString();
Assert.assertEquals(TestUtil.RESPONSES_MUST_MATCH, expectedStr, actualStr);
}
use of neo.model.network.GetBlocksPayload in project neo-java by coranos.
the class TestPayload method test004GetBlocksPayloadGenesis.
/**
* tests the GetBlocksPayload getting the genesis block.
*/
@Test
public void test004GetBlocksPayloadGenesis() {
final GetBlocksPayload payload = new GetBlocksPayload(GenesisBlockUtil.GENESIS_HASH, null);
final String expectedStr = new JSONObject(TestUtil.getJsonTestResourceAsString(TEST_PACKAGE, getClass().getSimpleName(), "test004GetBlocksPayloadGenesis")).toString();
final String actualStr = payload.toString();
Assert.assertEquals(TestUtil.RESPONSES_MUST_MATCH, expectedStr, actualStr);
}
use of neo.model.network.GetBlocksPayload in project neo-java by coranos.
the class MessageUtil method sendGetHeaders.
/**
* send a message to get header data.
*
* @param remoteNodeData
* the remote node data to use.
* @param localNodeData
* the local node data to use.
* @param hash
* the hash to use.
*/
public static void sendGetHeaders(final RemoteNodeData remoteNodeData, final LocalNodeData localNodeData, final UInt256 hash) {
LOG.debug("sendGetHeaders requesting hash:{};", hash);
remoteNodeData.send(new Message(localNodeData.getMagic(), CommandEnum.GETHEADERS, new GetBlocksPayload(hash, null).toByteArray()));
}
use of neo.model.network.GetBlocksPayload in project neo-java by coranos.
the class TestPayload method test003GetBlocksPayload.
/**
* tests the GetBlocksPayload.
*/
@Test
public void test003GetBlocksPayload() {
final String payloadJsonStrRaw = TestUtil.getJsonTestResourceAsString(TEST_PACKAGE, getClass().getSimpleName(), "test003GetBlocksPayloadHex");
final String payloadJsonStr = TestUtil.fromHexJsonObject(new JSONObject(payloadJsonStrRaw));
final byte[] payloadBa = ModelUtil.decodeHex(payloadJsonStr);
final GetBlocksPayload payload = new GetBlocksPayload(ByteBuffer.wrap(payloadBa));
Assert.assertNotNull("GetBlocksPayload should not be null", payload);
final String expectedStr = new JSONObject(TestUtil.getJsonTestResourceAsString(TEST_PACKAGE, getClass().getSimpleName(), "test003GetBlocksPayload")).toString();
final String actualStr = payload.toString();
Assert.assertEquals(TestUtil.RESPONSES_MUST_MATCH, expectedStr, actualStr);
final String expectedHexStr = new JSONObject(payloadJsonStrRaw).toString(2);
final String actualHexStr = TestUtil.toHexJsonObject(ModelUtil.toHexString(payload.toByteArray())).toString(2);
Assert.assertEquals(TestUtil.RESPONSES_MUST_MATCH, expectedHexStr, actualHexStr);
}
Aggregations