use of neo.rpc.client.test.util.AbstractJsonMockBlockDb in project neo-java by coranos.
the class TestBlockSerialization method test00ZAllBlocks.
/**
* pulls all the blocks (slow) to check for full coverage.
*
* @throws ClientProtocolException
* if an error occurs.
* @throws IOException
* if an error occurs.
* @throws DecoderException
* if an error occurs.
* @throws InterruptedException
* if an error occurs.
*/
@Test
@Ignore
public void test00ZAllBlocks() throws ClientProtocolException, IOException, DecoderException, InterruptedException {
final BlockDb blockDb = new AbstractJsonMockBlockDb() {
@Override
public JSONArray getMockBlockDb() {
return new JSONArray();
}
};
final long maxBlockIx = blockDb.getHeaderOfBlockWithMaxIndex().getIndexAsLong();
final Set<TransactionType> knownTypeSet = new TreeSet<>();
for (long blockIx = 0; blockIx <= maxBlockIx; blockIx++) {
final Block block = blockDb.getFullBlockFromHeight(blockIx);
for (int txIx = 0; txIx < block.getTransactionList().size(); txIx++) {
final Transaction tx = block.getTransactionList().get(txIx);
if (!knownTypeSet.contains(tx.type)) {
LOG.error("getBlock {} {} tx {} {}", block.getIndexAsLong(), block.prevHash, txIx, tx.type);
knownTypeSet.add(tx.type);
}
}
}
blockDb.close();
}
use of neo.rpc.client.test.util.AbstractJsonMockBlockDb in project neo-java by coranos.
the class TestBlockSerialization method testGetBlock.
/**
* test reading a miner transaction.
*/
@Test
@Ignore
public void testGetBlock() {
final BlockDb blockDb = new AbstractJsonMockBlockDb() {
@Override
public JSONArray getMockBlockDb() {
return new JSONArray();
}
};
try {
final String testName = "test001TxTypeMiner1";
final int blockIx = 1271700;
final String expectedBlockJsonStr = IOUtils.toString(this.getClass().getResourceAsStream("/neo/rpc/client/test/TestBlockSerialization." + testName + ".json"), "UTF-8");
final Block block = blockDb.getFullBlockFromHeight(blockIx);
final String actualBlockHex = ModelUtil.toHexString(block.toByteArray());
final JSONObject actualBlockJson = TestUtil.toHexJsonObject(actualBlockHex);
final String actualBlockJsonStr = actualBlockJson.toString(2);
Assert.assertEquals("hex encodings of blocks must match", expectedBlockJsonStr, actualBlockJsonStr);
} catch (final Exception e) {
throw new RuntimeException(e);
} finally {
blockDb.close();
}
}
Aggregations