Ejemplo n.º 1
0
  @Test
  public void responseWithoutDescriptionsCanBeRoundTripped() {
    // Act:
    final ErrorResponse response =
        createRoundTrippedResponse(new ErrorResponse(new TimeInstant(54), null, 890));

    // Assert:
    Assert.assertThat(response.getTimeStamp(), IsEqual.equalTo(new TimeInstant(54)));
    Assert.assertThat(response.getError(), IsNull.nullValue());
    Assert.assertThat(response.getMessage(), IsNull.nullValue());
    Assert.assertThat(response.getStatus(), IsEqual.equalTo(890));
  }
Ejemplo n.º 2
0
  @Test
  public void canBeCreatedAroundUnknownHttpStatus() {
    // Arrange:
    final ErrorResponse response =
        new ErrorResponse(new TimeInstant(18), "exception message", -123);

    // Assert:
    Assert.assertThat(response.getTimeStamp(), IsEqual.equalTo(new TimeInstant(18)));
    Assert.assertThat(response.getError(), IsNull.nullValue());
    Assert.assertThat(response.getMessage(), IsEqual.equalTo("exception message"));
    Assert.assertThat(response.getStatus(), IsEqual.equalTo(-123));
  }
    @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());
    }