Skip to content

Commit

Permalink
fix mock
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Jan 29, 2025
1 parent a87c956 commit 6347c4f
Showing 1 changed file with 4 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.PendingTransaction;
import org.hyperledger.besu.datatypes.Transaction;
import org.hyperledger.besu.datatypes.parameters.UnsignedLongParameter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Answers;

class LineaLimitedBundlePoolTest {

Expand Down Expand Up @@ -73,7 +73,8 @@ void smokeTestGetBundlesByBlockNumber() {
@Test
void smokeTestGetBundleByPendingTransaction() {
Hash hash = Hash.fromHexStringLenient("0x1234");
PendingTransaction pendingTransaction = new MockPendingTransaction();
PendingTransaction pendingTransaction =
mock(PendingTransaction.class, Answers.RETURNS_DEEP_STUBS);
LineaLimitedBundlePool.TransactionBundle bundle =
new LineaLimitedBundlePool.TransactionBundle(
hash,
Expand Down Expand Up @@ -119,29 +120,4 @@ private LineaLimitedBundlePool.TransactionBundle createBundle(Hash hash, long bl
Optional.empty(),
Optional.empty());
}

class MockPendingTransaction implements PendingTransaction {

@Override
public Transaction getTransaction() {
return new org.hyperledger.besu.ethereum.core.Transaction.Builder()
.payload(Bytes32.random())
.build();
}

@Override
public boolean isReceivedFromLocalSource() {
return false;
}

@Override
public boolean hasPriority() {
return false;
}

@Override
public long getAddedAt() {
return 0;
}
}
}

0 comments on commit 6347c4f

Please sign in to comment.