Skip to content

Commit 06b8b33

Browse files
author
Dmitry Voronov
committed
Fixed test to advance time programmaticaly
1 parent a9caf47 commit 06b8b33

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/main/scala/io/iohk/ethereum/db/cache/SimpleLRU.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class SimpleLRU[K](maxElements: Int, ttlMillis: Long) {
2424
* false - if not
2525
*/
2626
def checkAndRefreshEntry(key: K): Boolean = inner.synchronized {
27-
val existing = Option(inner.put(key, currentTime))
27+
val existing = Option(inner.put(key, getCurrentTime))
2828
existing.exists(!tooOld(_))
2929
}
3030

3131
// Override this to test
32-
protected def currentTime: Long = System.currentTimeMillis()
32+
protected def getCurrentTime: Long = System.currentTimeMillis()
3333

34-
private[this] def tooOld(time: Long) = time + ttlMillis < currentTime
34+
private[this] def tooOld(time: Long) = time + ttlMillis < getCurrentTime
3535

3636
}

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/JsonRpcHttpServer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ trait JsonRpcHttpServer extends Json4sSupport with Logger {
5454
}
5555
.result()
5656

57-
val rateLimit = new RateLimit(config.rateLimit)
57+
protected val rateLimit = new RateLimit(config.rateLimit)
5858

5959
val route: Route = cors(corsSettings) {
6060
(path("healthcheck") & pathEndOrSingleSlash & get) {

src/test/scala/io/iohk/ethereum/db/cache/SimpleLRUSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class SimpleLRUSpec extends AnyWordSpec {
77
var time = 0L
88

99
private object MockedLRU extends SimpleLRU[Int](10, 100) {
10-
override protected def currentTime: Long = SimpleLRUSpec.this.time
10+
override protected def getCurrentTime: Long = SimpleLRUSpec.this.time
1111
}
1212

1313
"It" should {

0 commit comments

Comments
 (0)