Skip to content

Commit

Permalink
Merge pull request #733 from wavesplatform/NODE-409-business-tests-fixes
Browse files Browse the repository at this point in the history
NODE-409 Business tests fixes
  • Loading branch information
alexeykiselev authored Dec 12, 2017
2 parents 5fbdac9 + de3441c commit f427812
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/it/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logback.stdout.level:-DEBUG}</level>
</filter>
<encoder>
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{26} - %msg%n</pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logback.file.level:-TRACE}</level>
</filter>
<file>${waves.it.logging.dir:-target/logs}/test.log</file>
<append>false</append>
<encoder>
Expand All @@ -19,7 +25,7 @@
<logger name="io.netty" level="INFO"/>
<logger name="io.swagger" level="OFF"/>

<root level="DEBUG">
<root level="TRACE">
<appender-ref ref="${waves.it.logging.appender:-STDOUT}"/>
</root>
</configuration>
1 change: 1 addition & 0 deletions src/it/resources/template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ waves {
api-key-hash = 7L6GpLHhA5KyJTAVc8WFHwEcyTY8fC8rRbyMCiFnM4i
api-key-different-host = yes
}
wallet.file = null
}
8 changes: 5 additions & 3 deletions src/it/scala/com/wavesplatform/it/BlockHeadersTestSuite.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wavesplatform.it

import com.wavesplatform.it.api.MultipleNodesApi
import com.wavesplatform.it.api.NodeApi.{Block, BlockHeaders}

import scala.concurrent.{Await, Future}
Expand All @@ -13,11 +14,11 @@ import scorex.utils.ScorexLogging
import scala.util.Random

class BlockHeadersTestSuite extends FreeSpec with Matchers with BeforeAndAfterAll with CancelAfterFailure
with ScorexLogging {
with MultipleNodesApi with ReportingTestName with ScorexLogging {

private lazy val docker = Docker(getClass)

private lazy val nodes: Seq[Node] = docker.startNodes(
lazy val nodes: Seq[Node] = docker.startNodes(
NodeConfigs.newBuilder
.overrideBase(_.quorum(2))
.withDefault(2)
Expand All @@ -32,6 +33,7 @@ class BlockHeadersTestSuite extends FreeSpec with Matchers with BeforeAndAfterAl
override protected def beforeAll(): Unit = {
super.beforeAll()
log.debug(s"There are ${nodes.size} in tests") // Initializing of a lazy variable
Await.result(traverse(nodes)(_.waitForHeight(2)), 1.minute)
}

override protected def afterAll(): Unit = {
Expand Down Expand Up @@ -93,7 +95,7 @@ class BlockHeadersTestSuite extends FreeSpec with Matchers with BeforeAndAfterAl
val f = for {
baseHeight <- traverse(nodes)(_.height).map(_.max)
_ <- txRequestsGen(30, 2.waves)
_ <- traverse(nodes)(_.waitForHeight(baseHeight + 10))
_ <- waitForSameBlocksAt(nodes, 3.seconds, baseHeight + 3)
blocks <- nodes.head.blockSeq(baseHeight + 1, baseHeight + 3)
blockHeaders <- nodes.head.blockHeadersSeq(baseHeight + 1, baseHeight + 3)
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import scorex.utils.ScorexLogging
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future.traverse

trait IntegrationNodesInitializationAndStopping extends BeforeAndAfterAll with ScorexLogging with ReportingTestName {
this: Suite =>
Expand All @@ -15,6 +16,7 @@ trait IntegrationNodesInitializationAndStopping extends BeforeAndAfterAll with S
abstract override def beforeAll(): Unit = {
super.beforeAll()
log.debug(s"There are ${nodes.size} in tests") // Initializing of a lazy variable
Await.result(traverse(nodes)(_.waitForHeight(2)), 1.minute)
}

abstract override def afterAll(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ trait IntegrationSuiteWithThreeAddresses extends BeforeAndAfterAll with Matchers
traverse(txNodePairs) { case (node, tx) => node.waitForTransaction(tx) }
}

val accounts = Seq(firstAddress, secondAddress, thirdAddress)

def makeTransfers: Future[Seq[String]] = traverse(accounts) { acc =>
def makeTransfers(accounts: Seq[String]): Future[Seq[String]] = traverse(accounts) { acc =>
sender.transfer(richAddress, acc, defaultBalance, sender.fee(TransactionType.TransferTransaction)).map(_.id)
}

val correctStartBalancesFuture = for {
_ <- traverse(nodes)(_.waitForHeight(2))
accounts = Seq(firstAddress, secondAddress, thirdAddress)

_ <- dumpBalances(sender, accounts, "initial")
txs <- makeTransfers
txs <- makeTransfers(accounts)

height <- traverse(nodes)(_.height).map(_.max)
_ <- withClue(s"waitForHeight(${height + 2})") {
Expand Down
17 changes: 14 additions & 3 deletions src/it/scala/com/wavesplatform/it/MicroblocksGenerationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.concurrent.Await.result
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

class MicroblocksGenerationSuite extends FreeSpec with IntegrationNodesInitializationAndStopping
class MicroblocksGenerationSuite extends FreeSpec with BeforeAndAfterAll
with Matchers with TransferSending with MultipleNodesApi {

private val txsInMicroBlock = 200
Expand Down Expand Up @@ -67,13 +67,24 @@ class MicroblocksGenerationSuite extends FreeSpec with IntegrationNodesInitializ
.map { x => x.recipient -> x.amount }
.toMap

override lazy val nodes: Seq[Node] = docker.startNodes(Seq(config))
lazy val docker: Docker = Docker(getClass)
lazy val nodes: Seq[Node] = docker.startNodes(Seq(config))
private lazy val miner = nodes.head

s"Generate transactions and wait for one block with $maxTxs txs" in result(for {
_ <- processRequests(generateTransfersToRandomAddresses(maxTxs, richAccountsWithBalance))
height <- miner.waitForHeight(3)
_ <- miner.waitForHeight(3)
block <- miner.blockAt(2)
} yield block.transactions.size shouldBe maxTxs, 3.minutes)

override def beforeAll(): Unit = {
super.beforeAll()
log.debug(s"There are ${nodes.size} in tests") // Initializing of a lazy variable
}

override def afterAll(): Unit = {
super.afterAll()
docker.close()
}

}

0 comments on commit f427812

Please sign in to comment.