-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEmptyEpochMinerEvictionTestSuite.scala
More file actions
52 lines (43 loc) · 2.06 KB
/
EmptyEpochMinerEvictionTestSuite.scala
File metadata and controls
52 lines (43 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package units
import com.wavesplatform.account.Address
import com.wavesplatform.state.{Height, IntegerDataEntry, StringDataEntry}
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.transaction.TxHelpers
import scala.concurrent.duration.*
import org.scalatest.concurrent.PatienceConfiguration.*
class EmptyEpochMinerEvictionTestSuite extends BaseDockerTestSuite {
private val reporter = miner11Account
private val idleMiner = miner21Account
private val idleMinerRewardAddress = miner21RewardAddress
"Another miner starts mining in the same epoch, in which the previous miner has been evicted" in {
// Set maxSkippedEpochCount (to speed up the test)
val maxSkippedEpochCount = 2
waves1.api.broadcastAndWait(
TxHelpers.dataEntry(chainContractAccount, IntegerDataEntry("maxSkippedEpochCount", maxSkippedEpochCount))
)
waves1.api.broadcastAndWait(
ChainContract.join(
minerAccount = idleMiner,
elRewardAddress = idleMinerRewardAddress
)
)
// Assertion: idle miner has successfully joined
waves1.api.dataByKey(chainContractAddress, "allMiners").value shouldBe
StringDataEntry("allMiners", s"${idleMiner.toAddress},${reporter.toAddress}")
val lastReportedHeight = eventually(Timeout(1.minute), Interval(2.seconds)) {
chainContract.waitForMinerEpoch(idleMiner)
val lastWavesBlock = waves1.api.blockHeader(waves1.api.height()).value
val vrf = ByteStr.decodeBase58(lastWavesBlock.VRF).get
// Report empty epoch
val h = waves1.api.broadcastAndWait(ChainContract.reportEmptyEpoch(reporter, vrf)).height
// Assertion: idle miner has been evicted
waves1.api.dataByKey(chainContractAddress, "allMiners").value shouldBe StringDataEntry("allMiners", s"${reporter.toAddress}")
h
}
// Assertion: reporter started mining on the same epoch, in which the previous miner has been evicted
val epochMeta = eventually {
chainContract.getEpochMeta(lastReportedHeight).value
}
epochMeta.miner shouldBe reporter.toAddress
}
}