@Override public Matcher visit(IsNull isNull) { return isNull .getField() .accept( new VisitorAdapter<Matcher>() { @Override public Matcher visit(final Field field) { return new Matcher() { @Override public boolean match(DataRecord record) { return record.get(field.getFieldMetadata()) == null; } }; } @Override public Matcher visit(StagingBlockKey stagingBlockKey) { return new Matcher() { @Override public boolean match(DataRecord record) { return record .getRecordMetadata() .getRecordProperties() .get(StagingStorage.METADATA_STAGING_BLOCK_KEY) == null; } }; } }); }
@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 nemesisTransactionSignersHavePublicKeys() { // Arrange: final Block block = this.loadNemesisBlock(); // Act: final Set<Address> signerAddresses = block .getTransactions() .stream() .map(t -> t.getSigner().getAddress()) .collect(Collectors.toSet()); // Assert: for (final Address address : signerAddresses) { Assert.assertThat(address.getPublicKey(), IsNull.notNullValue()); } }
@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()); }