### Question:
TargetChains { public void onPeerStatusUpdated(final SyncSource peer, final SlotAndBlockRoot chainHead) { removePeerFromLastChain(peer); chains.computeIfAbsent(chainHead, TargetChain::new).addPeer(peer); lastPeerTarget.put(peer, chainHead); }  void onPeerStatusUpdated(final SyncSource peer, final SlotAndBlockRoot chainHead); void onPeerDisconnected(final SyncSource peer); Stream<TargetChain> streamChains();  }### Answer:
@Test void onPeerStatus_shouldAddNewChainToTrack() { final SlotAndBlockRoot chainHead = dataStructureUtil.randomSlotAndBlockRoot(); targetChains.onPeerStatusUpdated(peer1, chainHead); assertTargetChains(chainWith(chainHead, peer1)); }
@Test void onPeerStatus_shouldAddPeerToExistingChain() { final SlotAndBlockRoot chainHead = dataStructureUtil.randomSlotAndBlockRoot(); targetChains.onPeerStatusUpdated(peer1, chainHead); targetChains.onPeerStatusUpdated(peer2, chainHead); assertTargetChains(chainWith(chainHead, peer1, peer2)); }
@Test void onPeerStatus_shouldAddPeerToDifferentChain() { final SlotAndBlockRoot chainHead1 = dataStructureUtil.randomSlotAndBlockRoot(); final SlotAndBlockRoot chainHead2 = dataStructureUtil.randomSlotAndBlockRoot(); targetChains.onPeerStatusUpdated(peer1, chainHead1); targetChains.onPeerStatusUpdated(peer2, chainHead2); assertTargetChains(chainWith(chainHead1, peer1), chainWith(chainHead2, peer2)); }
@Test void onPeerStatus_shouldMovePeerToDifferentChainWhenStatusChanges() { final SlotAndBlockRoot chainHead1 = dataStructureUtil.randomSlotAndBlockRoot(); final SlotAndBlockRoot chainHead2 = dataStructureUtil.randomSlotAndBlockRoot(); targetChains.onPeerStatusUpdated(peer1, chainHead1); targetChains.onPeerStatusUpdated(peer2, chainHead1); targetChains.onPeerStatusUpdated(peer1, chainHead2); assertTargetChains(chainWith(chainHead1, peer2), chainWith(chainHead2, peer1)); }
@Test void onPeerStatus_shouldRemoveChainWhenLastPeerChangesToADifferentChain() { final SlotAndBlockRoot chainHead1 = dataStructureUtil.randomSlotAndBlockRoot(); final SlotAndBlockRoot chainHead2 = dataStructureUtil.randomSlotAndBlockRoot(); targetChains.onPeerStatusUpdated(peer1, chainHead1); targetChains.onPeerStatusUpdated(peer1, chainHead2); assertTargetChains(chainWith(chainHead2, peer1)); }