Skip to content

Commit

Permalink
Fix tests after renaming fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirlogachev committed Nov 15, 2024
1 parent 389353f commit a7240c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 3 additions & 2 deletions node-it/src/test/scala/com/wavesplatform/it/Docker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class Docker(
private def getNodeInfo(containerId: String, settings: WavesSettings): NodeInfo = {
val restApiPort = settings.restAPISettings.port
// assume test nodes always have an open port
val networkPort = settings.networkSettings.bindAddress.get.getPort
val networkPort = settings.networkSettings.derivedBindAddress.get.getPort

val containerInfo = inspectContainer(containerId)
val wavesIpAddress = containerInfo.networkSettings().networks().get(wavesNetwork.name()).ipAddress()
Expand Down Expand Up @@ -601,7 +601,8 @@ object Docker {
}

AddressScheme.current = new AddressScheme {
override val chainId: Byte = ConfigSource.fromConfig(configTemplate).at("waves.blockchain.custom.address-scheme-character").loadOrThrow[String].charAt(0).toByte
override val chainId: Byte =
ConfigSource.fromConfig(configTemplate).at("waves.blockchain.custom.address-scheme-character").loadOrThrow[String].charAt(0).toByte
}

def apply(owner: Class[?]): Docker = new Docker(tag = owner.getSimpleName)
Expand Down
2 changes: 1 addition & 1 deletion node-it/src/test/scala/com/wavesplatform/it/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class Node(val config: Config) extends AutoCloseable {

object Node {
implicit class NodeExt(val n: Node) extends AnyVal {
def name: String = n.settings.networkSettings.nodeName
def name: String = n.settings.networkSettings.derivedNodeName
def publicKeyStr: String = n.publicKey.toString
def fee(txTypeId: Byte): Long = FeeValidation.FeeConstants(TransactionType(txTypeId)) * FeeValidation.FeeUnit
def blockDelay: FiniteDuration = n.settings.blockchainSettings.genesisSettings.averageBlockDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.typesafe.config.ConfigFactory
import com.wavesplatform.test.FlatSpec
import pureconfig.ConfigSource
import pureconfig.generic.auto.*
import pureconfig.error.ConfigReaderException
import scala.concurrent.duration.*

class NetworkSettingsSpecification extends FlatSpec {
Expand Down Expand Up @@ -67,32 +66,32 @@ class NetworkSettingsSpecification extends FlatSpec {
val config = loadConfig(ConfigFactory.empty())
val networkSettings = ConfigSource.fromConfig(config).at("waves.network").loadOrThrow[NetworkSettings]

networkSettings.nonce should not be 0
networkSettings.derivedNonce should not be 0
}

it should "build node name using nonce" in {
val config = loadConfig(ConfigFactory.parseString("waves.network.nonce = 12345"))
val networkSettings = ConfigSource.fromConfig(config).at("waves.network").loadOrThrow[NetworkSettings]

networkSettings.nonce should be(12345)
networkSettings.nodeName should be("Node-12345")
networkSettings.derivedNonce should be(12345)
networkSettings.derivedNodeName should be("Node-12345")
}

it should "build node name using random nonce" in {
val config = loadConfig(ConfigFactory.empty())
val networkSettings = ConfigSource.fromConfig(config).at("waves.network").loadOrThrow[NetworkSettings]

networkSettings.nonce should not be 0
networkSettings.nodeName should be(s"Node-${networkSettings.nonce}")
networkSettings.derivedNonce should not be 0
networkSettings.derivedNodeName should be(s"Node-${networkSettings.derivedNonce}")
}

it should "fail with ConfigReaderException on too long node name" in {
it should "fail with IllegalArgumentException on too long node name" in {
val config = loadConfig(
ConfigFactory.parseString(
"waves.network.node-name = очень-длинное-название-в-многобайтной-кодировке-отличной-от-однобайтной-кодировки-американского-института-стандартов"
)
)
intercept[ConfigReaderException[NetworkSettings]] {
intercept[IllegalArgumentException] {
ConfigSource.fromConfig(config).at("waves.network").loadOrThrow[NetworkSettings]
}
}
Expand Down

0 comments on commit a7240c4

Please sign in to comment.