diff --git a/consensus-client-it/src/test/scala/units/AlternativeChainTestSuite.scala b/consensus-client-it/src/test/scala/units/AlternativeChainTestSuite.scala index 14a635a..9a37642 100644 --- a/consensus-client-it/src/test/scala/units/AlternativeChainTestSuite.scala +++ b/consensus-client-it/src/test/scala/units/AlternativeChainTestSuite.scala @@ -1,5 +1,6 @@ package units +import com.wavesplatform.account.KeyPair import com.wavesplatform.api.LoggingBackend.LoggingOptions import com.wavesplatform.api.http.ApiError.ScriptExecutionError import com.wavesplatform.common.state.ByteStr @@ -9,37 +10,39 @@ import scala.annotation.tailrec class AlternativeChainTestSuite extends BaseDockerTestSuite { "L2-383 Start an alternative chain after not getting an EL-block" in { - step("Wait miner #1 forge at least one block") + step(s"Wait miner 1 (${miner11Account.toAddress}) forge at least one block") chainContract.waitForHeight(1L) - step("EL miner #2 join") + step(s"EL miner 2 (${miner21Account.toAddress}) join") + val heightBeforeJoin = waves1.api.height() waves1.api.broadcastAndWait( ChainContract.join( minerAccount = miner21Account, elRewardAddress = miner21RewardAddress ) ) + waves1.api.waitForHeight(heightBeforeJoin + 1) // "designatedMiner" calculates correctly - step("Wait miner #2 epoch and issue a block confirmation") - broadcastElBlockConfirmation() + step(s"Wait miner 2 (${miner21Account.toAddress}) epoch and issue a block confirmation") + broadcastElBlockConfirmation(miner21Account) - step("Wait miner #1 epoch") + step(s"Wait miner 1 (${miner11Account.toAddress}) epoch") chainContract.waitForMinerEpoch(miner11Account) step("Checking an alternative chain started") chainContract.waitForChainId(1L) } - @tailrec private def broadcastElBlockConfirmation(maxAttempts: Int = 5)(implicit + @tailrec private def broadcastElBlockConfirmation(minerAccount: KeyPair, maxAttempts: Int = 5)(implicit loggingOptions: LoggingOptions = LoggingOptions(logCall = false, logRequest = false) ): Unit = { if (maxAttempts == 0) fail("Can't broadcast an EL-block confirmation: all attempts are out") - chainContract.waitForMinerEpoch(miner21Account) + chainContract.waitForMinerEpoch(minerAccount) val lastContractBlock = chainContract.getLastBlockMeta(0).value - val lastWavesBlock = waves1.api.blockHeader(waves1.api.height).value + val lastWavesBlock = waves1.api.blockHeader(waves1.api.height()).value val txn = ChainContract.extendMainChain( - minerAccount = miner21Account, + minerAccount = minerAccount, blockHash = BlockHash("0x0000000000000000000000000000000000000000000000000000000000000001"), parentBlockHash = lastContractBlock.hash, e2cTransfersRootHashHex = EmptyE2CTransfersRootHashHex, @@ -49,7 +52,7 @@ class AlternativeChainTestSuite extends BaseDockerTestSuite { waves1.api.broadcast(txn) match { case Left(e) if e.error == ScriptExecutionError.Id => log.debug(s"Failed to send an EL-block confirmation: $e") - broadcastElBlockConfirmation(maxAttempts - 1) + broadcastElBlockConfirmation(minerAccount, maxAttempts - 1) case Left(e) => fail(s"Can't broadcast an EL-block confirmation: $e") case _ => waves1.api.waitForSucceeded(txn.id()) }