### Question:
TransactionPool implements BlockAddedObserver { public long subscribePendingTransactions(final PendingTransactionListener listener) { return pendingTransactions.subscribePendingTransactions(listener); } TransactionPool(
      final PendingTransactions pendingTransactions,
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final TransactionBatchAddedListener transactionBatchAddedListener,
      final Optional<TransactionBatchAddedListener> pendingTransactionBatchAddedListener,
      final SyncState syncState,
      final EthContext ethContext,
      final PeerTransactionTracker peerTransactionTracker,
      final Optional<PeerPendingTransactionTracker> maybePeerPendingTransactionTracker,
      final Wei minTransactionGasPrice,
      final MetricsSystem metricsSystem,
      final Optional<EIP1559> eip1559,
      final TransactionPoolConfiguration configuration); Collection<Hash> getNewPooledHashes(); boolean addTransactionHash(final Hash transactionHash); ValidationResult<TransactionInvalidReason> addLocalTransaction(
      final Transaction transaction); void addRemoteTransactions(final Collection<Transaction> transactions); long subscribePendingTransactions(final PendingTransactionListener listener); void unsubscribePendingTransactions(final long id); long subscribeDroppedTransactions(final PendingTransactionDroppedListener listener); void unsubscribeDroppedTransactions(final long id); @Override void onBlockAdded(final BlockAddedEvent event); PendingTransactions getPendingTransactions(); Optional<Transaction> getTransactionByHash(final Hash hash);  }### Answer:
@Test public void shouldReadTransactionsFromThePreviousCanonicalHeadWhenAReorgOccurs() { givenTransactionIsValid(transaction1); givenTransactionIsValid(transaction2); transactions.addRemoteTransaction(transaction1); transactions.addRemoteTransaction(transaction2); final BlockHeader commonParent = getHeaderForCurrentChainHead(); final Block originalFork1 = appendBlock(Difficulty.of(1000), commonParent, transaction1); final Block originalFork2 = appendBlock(Difficulty.ONE, originalFork1.getHeader(), transaction2); assertTransactionNotPending(transaction1); assertTransactionNotPending(transaction2); final Block reorgFork1 = appendBlock(Difficulty.ONE, commonParent); verifyChainHeadIs(originalFork2); transactions.subscribePendingTransactions(listener); final Block reorgFork2 = appendBlock(Difficulty.of(2000), reorgFork1.getHeader()); verifyChainHeadIs(reorgFork2); assertTransactionPending(transaction1); assertTransactionPending(transaction2); verify(listener).onTransactionAdded(transaction1); verify(listener).onTransactionAdded(transaction2); verifyNoMoreInteractions(listener); }