Tabnine Logo
BestBlock.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
io.yggdrash.core.net.BestBlock

Best Java code snippets using io.yggdrash.core.net.BestBlock.of (Showing top 6 results out of 315)

origin: yggdrash/yggdrash

  private BestBlock toBestBlock(Proto.BestBlock bestBlock) {
    BranchId branchId = BranchId.of(bestBlock.getBranch().toByteArray());
    long index = bestBlock.getIndex();
    return BestBlock.of(branchId, index);
  }
}
origin: yggdrash/yggdrash

  @Test
  public void shouldBeUniqueSameBranchInTheList() {
    // arrange
    BestBlock bb1 = BestBlock.of(branchId, 0);
    BestBlock bb2 = BestBlock.of(branchId, 2);
    assert bb1.hashCode() == bb2.hashCode();
    assert bb1.equals(bb2);

    // act
    Set<BestBlock> bestBlocks = new HashSet<>();
    bestBlocks.add(bb1);
    bestBlocks.add(bb2);

    // assert
    assert bestBlocks.size() == 1;

    // act again
    bestBlocks.add(BestBlock.of(TestConstants.YEED, 0));

    // assert again
    assert bestBlocks.size() == 2;

  }
}
origin: yggdrash/yggdrash

  @Test
  public void testBestBlock() {
    // arrange
    Peer peer = Peer.valueOf("ynode://75bff16c@127.0.0.1:32918");
    BestBlock bb = BestBlock.of(TestConstants.STEM, 0);

    // act
    peer.updateBestBlock(bb);

    //assert
    assertThat(peer.getBestBlocks()).containsOnly(bb);
  }
}
origin: yggdrash/yggdrash

@Test
public void findPeers() {
  doAnswer((invocationOnMock) -> {
    StreamObserver<Proto.BlockList> argument = invocationOnMock.getArgument(1);
    argument.onNext(null);
    argument.onCompleted();
    return null;
  }).when(peerService).findPeers(findPeersRequestCaptor.capture(), any());
  Peer owner = Peer.valueOf("ynode://75bff16c@127.0.0.1:32918");
  owner.updateBestBlock(BestBlock.of(TestConstants.STEM, 0));
  peerHandler.findPeers(owner);
  verify(peerService).findPeers(findPeersRequestCaptor.capture(), any());
  assertEquals("127.0.0.1", findPeersRequestCaptor.getValue().getIp());
  assertEquals(32918, findPeersRequestCaptor.getValue().getPort());
  Proto.BestBlock bestBlock = findPeersRequestCaptor.getValue().getBestBlocks(0);
  assertArrayEquals(TestConstants.STEM.getBytes(), bestBlock.getBranch().toByteArray());
  assertEquals(0, bestBlock.getIndex());
}
origin: yggdrash/yggdrash

@Test
public void testBestBlock() {
  BestBlock bb = BestBlock.of(branchId, 0);
  assert bb.getBranchId().equals(branchId);
  assert bb.getIndex() == 0;
}
origin: yggdrash/yggdrash

  @Test
  public void testUpdatedWithLatestPeer() {
    // arrange
    Peer newPeerWithBestBlock = Peer.valueOf(peer1.getYnodeUri());
    newPeerWithBestBlock.updateBestBlock(BestBlock.of(TestConstants.STEM, 0));

    bucket.addPeer(peer1);
    assert bucket.findByPeer(peer1).getBestBlocks().size() == 0;

    // act
    bucket.addPeer(newPeerWithBestBlock);

    // assert
    assert bucket.getPeers().size() == 1;
    assert bucket.findByPeer(peer1).getBestBlocks().size() == 1;
  }
}
io.yggdrash.core.netBestBlockof

Popular methods of BestBlock

  • getBranchId
  • getIndex
  • <init>
  • equals
  • hashCode
  • setBranchId
  • setIndex

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • getSupportFragmentManager (FragmentActivity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now