Skip to content

Commit 63012ca

Browse files
author
Jaap van der Plas
authored
ETCM-607 skip most mining-related assertions in EthashUtilsSpec on CI for faster builds (#920)
1 parent f98d2ef commit 63012ca

File tree

5 files changed

+127
-90
lines changed

5 files changed

+127
-90
lines changed

src/test/resources/application.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ faucet {
179179

180180
shutdown-timeout = 15.seconds
181181
}
182+
183+
# some super slow tests should be skipped on CI (eg. mining)
184+
skip-super-slow-tests = false
185+
skip-super-slow-tests = ${?CI}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.iohk.ethereum
2+
3+
import com.typesafe.config.ConfigFactory
4+
5+
trait SuperSlow {
6+
lazy private val skip = ConfigFactory.load().getBoolean("skip-super-slow-tests")
7+
8+
/**
9+
* Some assertions may be prohibitively slow and shouldn't run on every CI run. Use this method when that's the case.
10+
*
11+
* @param f slow tests
12+
*/
13+
def superSlow[T](f: => T): Option[T] =
14+
if (skip) None else Some(f)
15+
}

src/test/scala/io/iohk/ethereum/blockchain/sync/SyncSchedulerSpec.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ import org.scalatest.EitherValues
1919
import org.scalatest.flatspec.AnyFlatSpec
2020
import org.scalatest.matchers.must.Matchers
2121
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
22-
23-
class SyncSchedulerSpec extends AnyFlatSpec with Matchers with EitherValues with ScalaCheckPropertyChecks {
22+
import io.iohk.ethereum.SuperSlow
23+
24+
class SyncSchedulerSpec
25+
extends AnyFlatSpec
26+
with Matchers
27+
with EitherValues
28+
with ScalaCheckPropertyChecks
29+
with SuperSlow {
2430
"SyncScheduler" should "sync with mptTrie with one account (1 leaf node)" in new TestSetup {
2531
val prov = getTrieProvider
2632
val worldHash = prov.buildWorld(Seq(MptNodeData(Address(1), None, Seq(), 20)))
@@ -229,7 +235,10 @@ class SyncSchedulerSpec extends AnyFlatSpec with Matchers with EitherValues with
229235
// Long running test generating random mpt tries and checking that scheduler is able to correctly
230236
// traverse them
231237
it should "sync whole trie when receiving all nodes from remote side" in new TestSetup {
232-
forAll(genMultipleNodeData(2000)) { nodeData =>
238+
val nodeDataGen = genMultipleNodeData(
239+
superSlow(2000).getOrElse(20) // use smaller test set for CI as it is super slow there
240+
)
241+
forAll(nodeDataGen) { nodeData =>
233242
val prov = getTrieProvider
234243
val worldHash = prov.buildWorld(nodeData)
235244
val (scheduler, schedulerBlockchain, schedulerDb) = buildScheduler()

src/test/scala/io/iohk/ethereum/consensus/ethash/EthashUtilsSpec.scala

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import org.scalatest.flatspec.AnyFlatSpec
99
import org.scalatest.matchers.should.Matchers
1010

1111
import scala.annotation.tailrec
12+
import io.iohk.ethereum.SuperSlow
1213

13-
class EthashUtilsSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks {
14+
class EthashUtilsSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks with SuperSlow {
1415

1516
import io.iohk.ethereum.consensus.ethash.EthashUtils._
1617

@@ -61,77 +62,79 @@ class EthashUtilsSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyC
6162
proofOfWork.mixHash shouldBe ByteString(mixHash)
6263
proofOfWork.difficultyBoundary shouldBe ByteString(boundary)
6364

64-
val table = Table(
65-
("blockNumber", "hashWithoutNonce", "nonce", "mixHash"),
66-
(
67-
3521,
68-
"269d13f7ca546dced28ee26071dcb61085b7c54dfc5f93808b94885e136cd616",
69-
"534ab630b9aa1f68",
70-
"c6913517d1dc7544febde9f17e65d6ae4fa380d4a2a2d31305b0043caf95e717"
71-
),
72-
(
73-
5021,
74-
"7bd6c3c49a0627712c51f1abf0a7828bb25ebb8679d2584385a191db955667da",
75-
"413dc4ec1a0df7c4",
76-
"35890608f8867402052b2ce55a694b86a44ce87e7fb5412a77a025b184f25883"
77-
),
78-
(
79-
5091,
80-
"5b27820bfa3a059274ce17db0beea90ba0b6fbe6b49d2a23cbf972e8cde79319",
81-
"59225875d18ad606",
82-
"46f72f8b269461078e9d1cf4edf1b608f9d101e0f335ea59568c3436f291d01b"
83-
),
84-
(
85-
3091,
86-
"c37d980124cf83a4de4d9600f5bb6d3883797b84b7ec472feff6ca855c01d245",
87-
"745609efa9c4eef3",
88-
"c647fec06481b9f3f74cd771968d6d630aa11bf75ebd9e3c55ccfbae0fbad4da"
89-
),
90-
(
91-
1091,
92-
"c1c1efb8fdd4241a55db39e092fedae3df6d4abc13133778810027ade6557bc6",
93-
"4d9ddadaea6c20b2",
94-
"53624a7faac2ec82208348f7a11e3b38c880a2fec76dd8b47e434fe641eeacde"
95-
),
96-
(
97-
109,
98-
"aa234d4bcee14e93d127275dcc83504b6e730a14e9110bd09b68e1964f0daad3",
99-
"388e6b37c22147b7",
100-
"df14701b1ad6d3d5639956e463250960de3189a726cb38d71a6f6042f45dea72"
101-
),
102-
(
103-
1009,
104-
"3259779f9d2c477d29e18ead0ccc829bf2146723563c3e81e5e4886673d93bfb",
105-
"5faa044b70ccdf6b",
106-
"a1f1af0c2ca3e1d8e69da59fefbfeb4d0d172ec96bdbdac71b2cde49ddb3a828"
107-
),
108-
(
109-
1001,
110-
"028cc9a70d6db52c2a2606f04392e9a323d0370291d6c6d78bc8ce54acf1d761",
111-
"a54b5b31ce3de766",
112-
"819c26573f1a9cd6c4b9a399b72fbfb0084a104b25b62083533e114ee98a4831"
113-
),
114-
(
115-
1000,
116-
"15c5729eb017a703c13d00752338f6b55e2d2551b380706f0486f2ccca57ae1e",
117-
"eb610e766452a801",
118-
"a369e2fd5c4e357cf9f60ba063ae0baf32075b0d7ed80cd78134bc401db8f1bf"
119-
),
120-
(
121-
100,
122-
"41944a94a42695180b1ca231720a87825f17d36475112b659c23dea1542e0977",
123-
"37129c7f29a9364b",
124-
"5bb43c0772e58084b221c8e0c859a45950c103c712c5b8f11d9566ee078a4501"
65+
superSlow { // skip extra test cases on CI as it is super slow there
66+
val table = Table(
67+
("blockNumber", "hashWithoutNonce", "nonce", "mixHash"),
68+
(
69+
3521,
70+
"269d13f7ca546dced28ee26071dcb61085b7c54dfc5f93808b94885e136cd616",
71+
"534ab630b9aa1f68",
72+
"c6913517d1dc7544febde9f17e65d6ae4fa380d4a2a2d31305b0043caf95e717"
73+
),
74+
(
75+
5021,
76+
"7bd6c3c49a0627712c51f1abf0a7828bb25ebb8679d2584385a191db955667da",
77+
"413dc4ec1a0df7c4",
78+
"35890608f8867402052b2ce55a694b86a44ce87e7fb5412a77a025b184f25883"
79+
),
80+
(
81+
5091,
82+
"5b27820bfa3a059274ce17db0beea90ba0b6fbe6b49d2a23cbf972e8cde79319",
83+
"59225875d18ad606",
84+
"46f72f8b269461078e9d1cf4edf1b608f9d101e0f335ea59568c3436f291d01b"
85+
),
86+
(
87+
3091,
88+
"c37d980124cf83a4de4d9600f5bb6d3883797b84b7ec472feff6ca855c01d245",
89+
"745609efa9c4eef3",
90+
"c647fec06481b9f3f74cd771968d6d630aa11bf75ebd9e3c55ccfbae0fbad4da"
91+
),
92+
(
93+
1091,
94+
"c1c1efb8fdd4241a55db39e092fedae3df6d4abc13133778810027ade6557bc6",
95+
"4d9ddadaea6c20b2",
96+
"53624a7faac2ec82208348f7a11e3b38c880a2fec76dd8b47e434fe641eeacde"
97+
),
98+
(
99+
109,
100+
"aa234d4bcee14e93d127275dcc83504b6e730a14e9110bd09b68e1964f0daad3",
101+
"388e6b37c22147b7",
102+
"df14701b1ad6d3d5639956e463250960de3189a726cb38d71a6f6042f45dea72"
103+
),
104+
(
105+
1009,
106+
"3259779f9d2c477d29e18ead0ccc829bf2146723563c3e81e5e4886673d93bfb",
107+
"5faa044b70ccdf6b",
108+
"a1f1af0c2ca3e1d8e69da59fefbfeb4d0d172ec96bdbdac71b2cde49ddb3a828"
109+
),
110+
(
111+
1001,
112+
"028cc9a70d6db52c2a2606f04392e9a323d0370291d6c6d78bc8ce54acf1d761",
113+
"a54b5b31ce3de766",
114+
"819c26573f1a9cd6c4b9a399b72fbfb0084a104b25b62083533e114ee98a4831"
115+
),
116+
(
117+
1000,
118+
"15c5729eb017a703c13d00752338f6b55e2d2551b380706f0486f2ccca57ae1e",
119+
"eb610e766452a801",
120+
"a369e2fd5c4e357cf9f60ba063ae0baf32075b0d7ed80cd78134bc401db8f1bf"
121+
),
122+
(
123+
100,
124+
"41944a94a42695180b1ca231720a87825f17d36475112b659c23dea1542e0977",
125+
"37129c7f29a9364b",
126+
"5bb43c0772e58084b221c8e0c859a45950c103c712c5b8f11d9566ee078a4501"
127+
)
125128
)
126-
)
127129

128-
forAll(table) { (blockNumber, hashWithoutNonce, nonce, mixHash) =>
129-
val _epoch = epoch(blockNumber, ecip1099forkBlockNumber)
130-
val _seed = seed(blockNumber)
131-
val cache = makeCache(_epoch, _seed)
132-
val proofOfWork =
133-
hashimotoLight(Hex.decode(hashWithoutNonce), Hex.decode(nonce), dagSize(_epoch), cache)
134-
proofOfWork.mixHash shouldBe ByteString(Hex.decode(mixHash))
130+
forAll(table) { (blockNumber, hashWithoutNonce, nonce, mixHash) =>
131+
val _epoch = epoch(blockNumber, ecip1099forkBlockNumber)
132+
val _seed = seed(blockNumber)
133+
val cache = makeCache(_epoch, _seed)
134+
val proofOfWork =
135+
hashimotoLight(Hex.decode(hashWithoutNonce), Hex.decode(nonce), dagSize(_epoch), cache)
136+
proofOfWork.mixHash shouldBe ByteString(Hex.decode(mixHash))
137+
}
135138
}
136139
}
137140

src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
1616
import org.scalatest.flatspec.AnyFlatSpec
1717
import org.scalatest.matchers.should.Matchers
1818
import io.iohk.ethereum.domain.BlockHeader.HeaderExtraFields._
19+
import io.iohk.ethereum.SuperSlow
20+
import org.scalatest.prop.TableFor4
1921

2022
// scalastyle:off magic.number
2123
class BlockHeaderValidatorSpec
2224
extends AnyFlatSpec
2325
with Matchers
2426
with ScalaCheckPropertyChecks
2527
with ObjectGenerators
26-
with MockFactory {
28+
with MockFactory
29+
with SuperSlow {
2730

2831
val ExtraDataSizeLimit = 20
2932

@@ -48,23 +51,26 @@ class BlockHeaderValidatorSpec
4851

4952
it should "validate DAO block (extra data)" in {
5053
import Fixtures.Blocks._
51-
val cases = Table(
54+
val cases: TableFor4[BlockHeader, Block, Boolean, Boolean] = Table(
5255
("Block", "Parent Block", "Supports Dao Fork", "Valid"),
53-
(DaoForkBlock.header, DaoParentBlock.block, false, true),
54-
(DaoForkBlock.header, DaoParentBlock.block, true, false),
55-
(ProDaoForkBlock.header, DaoParentBlock.block, true, true),
56-
(ProDaoForkBlock.header, DaoParentBlock.block, false, true), // We don't care for extra data if no pro dao
57-
(ProDaoForkBlock.header.copy(extraData = ByteString("Wrond DAO Extra")), DaoParentBlock.block, true, false),
58-
// We need to check extradata up to 10 blocks after
59-
(ProDaoBlock1920009Header, Block(ProDaoBlock1920008Header, validParentBlockBody), true, true),
60-
(
61-
ProDaoBlock1920009Header.copy(extraData = ByteString("Wrond DAO Extra")),
62-
Block(ProDaoBlock1920008Header, validParentBlockBody),
63-
true,
64-
false
65-
),
66-
(ProDaoBlock1920010Header, Block(ProDaoBlock1920009Header, validParentBlockBody), true, true)
67-
)
56+
(DaoForkBlock.header, DaoParentBlock.block, false, true)
57+
) ++ superSlow { // skip extra test cases on CI as it is super slow there
58+
Seq(
59+
(DaoForkBlock.header, DaoParentBlock.block, true, false),
60+
(ProDaoForkBlock.header, DaoParentBlock.block, true, true),
61+
(ProDaoForkBlock.header, DaoParentBlock.block, false, true), // We don't care for extra data if no pro dao
62+
(ProDaoForkBlock.header.copy(extraData = ByteString("Wrond DAO Extra")), DaoParentBlock.block, true, false),
63+
// We need to check extradata up to 10 blocks after
64+
(ProDaoBlock1920009Header, Block(ProDaoBlock1920008Header, validParentBlockBody), true, true),
65+
(
66+
ProDaoBlock1920009Header.copy(extraData = ByteString("Wrond DAO Extra")),
67+
Block(ProDaoBlock1920008Header, validParentBlockBody),
68+
true,
69+
false
70+
),
71+
(ProDaoBlock1920010Header, Block(ProDaoBlock1920009Header, validParentBlockBody), true, true)
72+
)
73+
}.toSeq.flatten
6874

6975
forAll(cases) { (blockHeader, parentBlock, supportsDaoFork, valid) =>
7076
val blockHeaderValidator = new EthashBlockHeaderValidator(createBlockchainConfig(supportsDaoFork))

0 commit comments

Comments
 (0)