From dd38d842dd78eebd1daa7c10c0acde5febfa6b22 Mon Sep 17 00:00:00 2001 From: Vladimir Logachev Date: Mon, 18 Nov 2024 12:18:47 +0400 Subject: [PATCH] Add unit test for DBSettings --- .../settings/DbSettingsSpecification.scala | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 node/tests/src/test/scala/com/wavesplatform/settings/DbSettingsSpecification.scala diff --git a/node/tests/src/test/scala/com/wavesplatform/settings/DbSettingsSpecification.scala b/node/tests/src/test/scala/com/wavesplatform/settings/DbSettingsSpecification.scala new file mode 100644 index 0000000000..833f2d16be --- /dev/null +++ b/node/tests/src/test/scala/com/wavesplatform/settings/DbSettingsSpecification.scala @@ -0,0 +1,57 @@ +package com.wavesplatform.settings + +import com.typesafe.config.ConfigFactory +import com.wavesplatform.test.FlatSpec + +class DbSettingsSpecification extends FlatSpec { + "DbSettingsSpecification" should "read values from config" in { + val config = loadConfig(ConfigFactory.parseString("""waves.db { + | directory = "/data" + | store-transactions-by-address = true + | store-lease-states-by-address = true + | store-invoke-script-results = true + | store-state-hashes = false + | max-cache-size = 100000 + | max-rollback-depth = 2000 + | cleanup-interval = 500 + | rocksdb { + | main-cache-size = 512M + | tx-cache-size = 16M + | tx-meta-cache-size = 16M + | tx-snapshot-cache-size = 16M + | api-cache-size=16M + | write-buffer-size = 128M + | enable-statistics = false + | allow-mmap-reads = off + | parallelism = 2 + | max-open-files = 100 + | } + |}""".stripMargin)) + val actualDbSettings = DBSettings.fromConfig(config.getConfig("waves.db")) + + val expectedDbSettings: DBSettings = DBSettings( + directory = "/data", + storeTransactionsByAddress = true, + storeLeaseStatesByAddress = true, + storeInvokeScriptResults = true, + storeStateHashes = false, + maxCacheSize = 100000, + maxRollbackDepth = 2000, + cleanupInterval = Some(500), + rocksdb = RocksDBSettings( + mainCacheSize = SizeInBytes(512L * 1024 * 1024), + txCacheSize = SizeInBytes(16L * 1024 * 1024), + txMetaCacheSize = SizeInBytes(16L * 1024 * 1024), + txSnapshotCacheSize = SizeInBytes(16L * 1024 * 1024), + apiCacheSize = SizeInBytes(16L * 1024 * 1024), + writeBufferSize = SizeInBytes(128L * 1024 * 1024), + enableStatistics = false, + allowMmapReads = false, + parallelism = 2, + maxOpenFiles = 100 + ) + ) + + actualDbSettings should be(expectedDbSettings) + } +}