@Test public void addressConstantIsConsistentWithNemesisBlock() { // Arrange: final Block block = this.loadNemesisBlock(); final Address blockAddress = block.getSigner().getAddress(); // Assert: Assert.assertThat(blockAddress, IsEqual.equalTo(NEMESIS_BLOCK_INFO.getAddress())); Assert.assertThat( blockAddress.getPublicKey(), IsEqual.equalTo(NEMESIS_BLOCK_INFO.getAddress().getPublicKey())); Assert.assertThat(blockAddress.getPublicKey(), IsNull.notNullValue()); }
@Test public void generationHashConstantIsConsistentWithNemesisBlock() { // Arrange: final Block block = this.loadNemesisBlock(); // Assert: Assert.assertThat( block.getGenerationHash(), IsEqual.equalTo(NEMESIS_BLOCK_INFO.getGenerationHash())); }
private static byte[] loadNemesisBlockBlobObject() { try (final InputStream fin = NemesisBlock.class .getClassLoader() .getResourceAsStream(NEMESIS_BLOCK_INFO.getDataFileName())) { return IOUtils.toByteArray(fin); } catch (final IOException e) { throw new IllegalStateException( "unexpected exception was thrown when parsing nemesis block resource"); } }
@Test public void amountConstantIsConsistentWithNemesisBlock() { // Act: Amount totalAmount = Amount.ZERO; final Block block = this.loadNemesisBlock(); for (final Transaction transaction : block.getTransactions()) { if (transaction instanceof TransferTransaction) { totalAmount = totalAmount.add(((TransferTransaction) transaction).getAmount()); } } // Assert: Assert.assertThat(totalAmount, IsEqual.equalTo(NEMESIS_BLOCK_INFO.getAmount())); }
@Test public void nemesisBlockCanBeCreated() { // Act: final Block block = this.loadNemesisBlock(); // Assert: Assert.assertThat( block.getSigner().getAddress(), IsEqual.equalTo(NEMESIS_BLOCK_INFO.getAddress())); Assert.assertThat(block.getType(), IsEqual.equalTo(-1)); Assert.assertThat(block.getVersion(), IsEqual.equalTo(EXPECTED_VERSION)); Assert.assertThat(block.getTimeStamp(), IsEqual.equalTo(TimeInstant.ZERO)); // 2 multisig aggregate transactions Assert.assertThat( block.getTotalFee(), IsEqual.equalTo(EXPECTED_MULTISIG_AGGREGATE_FEE.multiply(2))); Assert.assertThat(block.getPreviousBlockHash(), IsEqual.equalTo(Hash.ZERO)); Assert.assertThat(block.getHeight(), IsEqual.equalTo(BlockHeight.ONE)); Assert.assertThat(block.getTransactions().size(), IsEqual.equalTo(NUM_NEMESIS_TRANSACTIONS)); Assert.assertThat(block.getDifficulty(), IsEqual.equalTo(BlockDifficulty.INITIAL_DIFFICULTY)); Assert.assertThat(block.getGenerationHash(), IsNull.notNullValue()); }