Skip to content

Commit

Permalink
created default handling of the operations, fixed tests and test gene…
Browse files Browse the repository at this point in the history
…ration (#1098)
  • Loading branch information
piotrkosecki authored Jun 29, 2022
1 parent 42b1148 commit 1b11a5e
Show file tree
Hide file tree
Showing 72 changed files with 13,753 additions and 13,629 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ class GenericPlatformDiscoveryOperations(
* @param xs list of platform-network pairs for which we want to fetch attribute values
* @return database action with attribute values to be cached
*/
def initAttributeValuesCache(xs: List[(Platform, Network)]): Future[Boolean] = {
def initAttributeValuesCache(xs: List[(Platform, Network)]): Future[Boolean] =
xs.map { case (platform, network) =>
IO.fromFuture(IO(dbRunners(platform.name, network.name).runQuery(preCacheAttributeValues(platform, network))))
}.sequence.map(_.reduce(_ ++ _)).flatMap(caching.fillAttributeValuesCache)
}.unsafeToFuture()
}.sequence
.map(_.reduce(_ ++ _))
.flatMap(caching.fillAttributeValuesCache)
.unsafeToFuture()

/** Pre-caching attribute values from slick for specific platform
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import scala.language.postfixOps
class ConseilAppConfigTest extends ConseilSpec {

"ConseilAppConfig" should {
"extract the correct configuration list for Tezos platform's networks using default readers" in {
import Platforms._
"extract the correct configuration list for Tezos platform's networks using default readers" in {
import Platforms._

val cfg = ConfigFactory.parseString("""
val cfg = ConfigFactory.parseString("""
|platforms: [
| {
| name: "tezos"
Expand Down Expand Up @@ -66,39 +66,39 @@ class ConseilAppConfigTest extends ConseilSpec {
|]
""".stripMargin)

val typedConfig = pureconfig.loadConfig[PlatformsConfiguration](conf = cfg)

typedConfig.right.value.platforms should contain only (
TezosConfiguration(
"alphanet",
enabled = true,
TezosNodeConfiguration("localhost", 8732, "http", "tezos/alphanet/"),
BigDecimal.decimal(8000),
cfg.getConfigList("platforms").get(0).getConfig("db"),
None
val typedConfig = pureconfig.loadConfig[PlatformsConfiguration](conf = cfg)

typedConfig.right.value.platforms should contain only (
TezosConfiguration(
"alphanet",
enabled = true,
TezosNodeConfiguration("localhost", 8732, "http", "tezos/alphanet/"),
BigDecimal.decimal(8000),
cfg.getConfigList("platforms").get(0).getConfig("db"),
None
),
TezosConfiguration(
"alphanet-staging",
enabled = false,
TezosNodeConfiguration(
"nautilus.cryptonomic.tech",
8732,
"https",
"tezos/alphanet-staging/",
traceCalls = true
),
TezosConfiguration(
"alphanet-staging",
enabled = false,
TezosNodeConfiguration(
"nautilus.cryptonomic.tech",
8732,
"https",
"tezos/alphanet-staging/",
traceCalls = true
),
BigDecimal.decimal(8000),
cfg.getConfigList("platforms").get(1).getConfig("db"),
None
)
BigDecimal.decimal(8000),
cfg.getConfigList("platforms").get(1).getConfig("db"),
None
)
)

}
}

"extract a configuration list that includes a unknown platforms" in {
import Platforms._
"extract a configuration list that includes a unknown platforms" in {
import Platforms._

val cfg = ConfigFactory.parseString("""
val cfg = ConfigFactory.parseString("""
|platforms: [
| {
| name: "tezos"
Expand Down Expand Up @@ -146,21 +146,21 @@ class ConseilAppConfigTest extends ConseilSpec {
|]
""".stripMargin)

val typedConfig = pureconfig.loadConfig[PlatformsConfiguration](conf = cfg)
typedConfig.left.value.toList should have size 1
typedConfig.left.value.toList.head shouldBe an[ConvertFailure]
}
val typedConfig = pureconfig.loadConfig[PlatformsConfiguration](conf = cfg)
typedConfig.left.value.toList should have size 1
typedConfig.left.value.toList.head shouldBe an[ConvertFailure]
}

"extract None, when configuration for Nautilus Cloud does not exist" in {
val config = ConfigFactory.parseString("")
val typedConfig =
pureconfig.loadConfig[Option[NautilusCloudConfiguration]](conf = config, namespace = "nautilus-cloud")
"extract None, when configuration for Nautilus Cloud does not exist" in {
val config = ConfigFactory.parseString("")
val typedConfig =
pureconfig.loadConfig[Option[NautilusCloudConfiguration]](conf = config, namespace = "nautilus-cloud")

typedConfig.value shouldBe empty
}
typedConfig.value shouldBe empty
}

"extract Some, when configuration for Nautilus Cloud exists" in {
val config = ConfigFactory.parseString("""
"extract Some, when configuration for Nautilus Cloud exists" in {
val config = ConfigFactory.parseString("""
|nautilus-cloud {
| enabled: true
| host: "http://localhost"
Expand All @@ -171,19 +171,19 @@ class ConseilAppConfigTest extends ConseilSpec {
| interval: 30 seconds
|}
|""".stripMargin)
val typedConfig =
pureconfig.loadConfig[Option[NautilusCloudConfiguration]](conf = config, namespace = "nautilus-cloud")

typedConfig.right.value.value shouldBe NautilusCloudConfiguration(
true,
"http://localhost",
1234,
"apiKeys/dev",
"exampleApiKeyDev",
10 seconds,
30 seconds
)
}
val typedConfig =
pureconfig.loadConfig[Option[NautilusCloudConfiguration]](conf = config, namespace = "nautilus-cloud")

typedConfig.right.value.value shouldBe NautilusCloudConfiguration(
true,
"http://localhost",
1234,
"apiKeys/dev",
"exampleApiKeyDev",
10 seconds,
30 seconds
)
}
}

}
Loading

0 comments on commit 1b11a5e

Please sign in to comment.