Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jan 24, 2022
1 parent e8381e4 commit 61f8bef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.tuweni.eth.crawler
import io.opentelemetry.api.metrics.Meter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand All @@ -31,7 +32,7 @@ class StatsJob(
private val upgradeConfigs: List<UpgradeConfig> = listOf(),
private val meter: Meter,
private val clientsStatsDelay: Long = 30 * 1000L,
override val coroutineContext: CoroutineContext
override val coroutineContext: CoroutineContext = Dispatchers.Default
) : CoroutineScope {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ class CrawlerRESTServiceTest {
@Test
fun startAndStop() = runBlocking {
val repo = mock<RelationalPeerRepository>()
val statsMeter = SdkMeterProvider.builder().build().get("stats")
val meter = SdkMeterProvider.builder().build().get("crawler")
val stats = StatsJob(repo, listOf(), statsMeter)

val service = CrawlerRESTService(repository = repo, meter = meter)
val service = CrawlerRESTService(repository = repo, meter = meter, stats = stats)
service.start().await()
service.stop().await()
Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class RelationalPeerRepositoryTest {

@Test
fun testGetNewPeer() = runBlocking {
val repository = RelationalPeerRepository(dataSource!!, meter = meter)
val repository = RelationalPeerRepository(dataSource!!)
val peer = repository.get("localhost", 30303, SECP256K1.KeyPair.random().publicKey())
assertNotNull(peer)
}

@Test
fun testUpdateEndpoint() = runBlocking {
val repository = RelationalPeerRepository(dataSource!!, meter = meter)
val repository2 = RelationalPeerRepository(dataSource!!, meter = meter)
val repository = RelationalPeerRepository(dataSource!!)
val repository2 = RelationalPeerRepository(dataSource!!)
val peer = repository.get("localhost", 30303, SECP256K1.KeyPair.random().publicKey())
assertNotNull(peer)
val lastSeen = 32L
Expand Down

0 comments on commit 61f8bef

Please sign in to comment.