Skip to content

Commit 7d7fd4e

Browse files
authored
[Chore] update scalatest (#689)
* [Chore] Update ScalaTest * [Chore] Update Scalamock * [Chore] Update repo.nix
1 parent 6a58490 commit 7d7fd4e

File tree

153 files changed

+1409
-700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+1409
-700
lines changed

project/Dependencies.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ object Dependencies {
5151
)
5252

5353
val testing: Seq[ModuleID] = Seq(
54-
"org.scalatest" %% "scalatest" % "3.0.8" % "it,test",
55-
"org.scalamock" %% "scalamock-scalatest-support" % "3.6.0" % "test",
54+
"org.scalatest" %% "scalatest" % "3.2.2" % "it,test",
55+
"org.scalamock" %% "scalamock" % "5.0.0" % "test",
56+
"org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % "test",
5657
"org.scalacheck" %% "scalacheck" % "1.14.1" % "it,test"
5758
)
5859

repo.nix

Lines changed: 512 additions & 136 deletions
Large diffs are not rendered by default.

src/benchmark/scala/io/iohk/ethereum/mpt/MerklePatriciaTreeSpeedSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import io.iohk.ethereum.mpt.MerklePatriciaTrie.defaultByteArraySerializable
66
import io.iohk.ethereum.utils.Logger
77
import io.iohk.ethereum.{ObjectGenerators, crypto}
88
import org.bouncycastle.util.encoders.Hex
9-
import org.scalatest.FunSuite
9+
import org.scalatest.funsuite.AnyFunSuite
1010
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
1111

1212
class MerklePatriciaTreeSpeedSpec
13-
extends FunSuite
13+
extends AnyFunSuite
1414
with ScalaCheckPropertyChecks
1515
with ObjectGenerators
1616
with Logger

src/benchmark/scala/io/iohk/ethereum/rlp/RLPSpeedSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import io.iohk.ethereum.domain._
77
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions._
88
import io.iohk.ethereum.utils.Logger
99
import org.scalacheck.Gen
10-
import org.scalatest.FunSuite
1110
import org.bouncycastle.util.encoders.Hex
11+
import org.scalatest.funsuite.AnyFunSuite
1212
import org.scalatestplus.scalacheck.{ScalaCheckDrivenPropertyChecks, ScalaCheckPropertyChecks}
1313

1414
/**
@@ -17,7 +17,7 @@ import org.scalatestplus.scalacheck.{ScalaCheckDrivenPropertyChecks, ScalaCheckP
1717
* - https://github.com/ethereum/pyrlp/blob/develop/tests/speed.py
1818
*/
1919
class RLPSpeedSuite
20-
extends FunSuite
20+
extends AnyFunSuite
2121
with ScalaCheckPropertyChecks
2222
with ScalaCheckDrivenPropertyChecks
2323
with ObjectGenerators

src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainSuite.scala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package io.iohk.ethereum.ets.blockchain
22

33
import java.util.concurrent.Executors
4+
45
import akka.actor.ActorSystem
56
import io.iohk.ethereum.domain.Block
67
import io.iohk.ethereum.ets.common.TestOptions
78
import io.iohk.ethereum.extvm.ExtVMInterface
89
import io.iohk.ethereum.ledger.Ledger.VMImpl
910
import io.iohk.ethereum.nodebuilder.VmSetup
1011
import io.iohk.ethereum.utils.{Config, Logger, VmConfig}
11-
import org.scalatest._
12+
import org.scalatest.{Args, BeforeAndAfterAll, Status}
13+
import org.scalatest.freespec.AnyFreeSpec
14+
import org.scalatest.matchers.should.Matchers
15+
1216
import scala.concurrent.duration.Duration
1317
import scala.concurrent.{Await, ExecutionContext, Future}
1418

@@ -18,7 +22,7 @@ object BlockchainSuite {
1822
lazy val extvm: VMImpl = VmSetup.vm(VmConfig(Config.config), Config.blockchains.blockchainConfig, testMode = true)
1923
}
2024

21-
class BlockchainSuite extends FreeSpec with Matchers with BeforeAndAfterAll with Logger {
25+
class BlockchainSuite extends AnyFreeSpec with Matchers with BeforeAndAfterAll with Logger {
2226
import BlockchainSuite.testContext
2327

2428
val unsupportedNetworks: Set[String] = Set(
@@ -60,7 +64,7 @@ class BlockchainSuite extends FreeSpec with Matchers with BeforeAndAfterAll with
6064
cancel(s"Unsupported network: ${scenario.network}")
6165
} else if (!supportedNetworks.contains(scenario.network)) {
6266
fail(s"Unknown network: ${scenario.network}")
63-
} else if (isCanceled(group.name, name)){
67+
} else if (isCanceled(group.name, name)) {
6468
cancel(s"Test: $name in group: ${group.name} not yet supported")
6569
} else {
6670
log.info(s"Running test: ${group.name}#$name")
@@ -82,7 +86,9 @@ class BlockchainSuite extends FreeSpec with Matchers with BeforeAndAfterAll with
8286
}
8387

8488
private def isCanceled(groupName: String, testName: String): Boolean =
85-
ignoredTests.get(groupName).isDefined && (ignoredTests(groupName).contains(testName) || ignoredTests(groupName).isEmpty)
89+
ignoredTests.get(groupName).isDefined && (ignoredTests(groupName).contains(testName) || ignoredTests(
90+
groupName
91+
).isEmpty)
8692

8793
private def runScenario(scenario: BlockchainScenario, setup: ScenarioSetup, name: String): Unit = {
8894

@@ -110,7 +116,9 @@ class BlockchainSuite extends FreeSpec with Matchers with BeforeAndAfterAll with
110116
val lastBlock = getBestBlock
111117

112118
val expectedWorldStateHash =
113-
scenario.postStateHash.orElse(finalWorld.map(_.stateRootHash)).getOrElse(throw new IllegalStateException("postState or PostStateHash not defined"))
119+
scenario.postStateHash
120+
.orElse(finalWorld.map(_.stateRootHash))
121+
.getOrElse(throw new IllegalStateException("postState or PostStateHash not defined"))
114122

115123
lastBlock shouldBe defined
116124

src/ets/scala/io/iohk/ethereum/ets/vm/VMSuite.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package io.iohk.ethereum.ets.vm
22

33
import akka.util.ByteString
4+
import io.iohk.ethereum.crypto.kec256
45
import io.iohk.ethereum.domain.TxLogEntry
56
import io.iohk.ethereum.ets.common.TestOptions
67
import io.iohk.ethereum.network.p2p.messages.PV63.TxLogEntryImplicits._
78
import io.iohk.ethereum.rlp._
89
import io.iohk.ethereum.utils.Logger
910
import io.iohk.ethereum.vm.MockWorldState._
1011
import io.iohk.ethereum.vm._
11-
import io.iohk.ethereum.crypto.kec256
1212
import org.scalatest._
13+
import org.scalatest.freespec.AnyFreeSpec
14+
import org.scalatest.matchers.should.Matchers
1315

14-
class VMSuite extends FreeSpec with Matchers with Logger {
16+
class VMSuite extends AnyFreeSpec with Matchers with Logger {
1517

1618
val vm = new TestVM
1719

@@ -79,7 +81,9 @@ class VMSuite extends FreeSpec with Matchers with Logger {
7981
result.internalTxs.flatMap(internalTxToCallCreate) shouldEqual callcreates
8082
}
8183

82-
if (scenario.gas.isEmpty && scenario.out.isEmpty && scenario.callcreates.isEmpty && scenario.post.isEmpty && scenario.logs.isEmpty) {
84+
if (
85+
scenario.gas.isEmpty && scenario.out.isEmpty && scenario.callcreates.isEmpty && scenario.post.isEmpty && scenario.logs.isEmpty
86+
) {
8387
result.error.isDefined shouldBe true
8488
}
8589
}

src/evmTest/scala/io/iohk/ethereum/vm/CallSelfDestructSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
4+
import org.scalatest.matchers.should.Matchers
5+
import org.scalatest.freespec.AnyFreeSpec
56

6-
class CallSelfDestructSpec extends FreeSpec with Matchers {
7+
class CallSelfDestructSpec extends AnyFreeSpec with Matchers {
78

89
"EVM running CallSelfDestruct contract" - {
910

src/evmTest/scala/io/iohk/ethereum/vm/CallerSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
4+
import org.scalatest.matchers.should.Matchers
5+
import org.scalatest.freespec.AnyFreeSpec
56
import io.iohk.ethereum.domain.UInt256
67

78
// scalastyle:off magic.number
8-
class CallerSpec extends FreeSpec with Matchers {
9+
class CallerSpec extends AnyFreeSpec with Matchers {
910

1011
"EVM running Caller contract" - {
1112

src/evmTest/scala/io/iohk/ethereum/vm/ContractCallingItselfSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
4+
import org.scalatest.matchers.should.Matchers
5+
import org.scalatest.freespec.AnyFreeSpec
56
import io.iohk.ethereum.domain.UInt256
67

78
// scalastyle:off magic.number
8-
class ContractCallingItselfSpec extends FreeSpec with Matchers {
9+
class ContractCallingItselfSpec extends AnyFreeSpec with Matchers {
910

1011
"EVM running ContractCallingItself contract" - {
1112

src/evmTest/scala/io/iohk/ethereum/vm/FibonacciSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
4+
import org.scalatest.matchers.should.Matchers
5+
import org.scalatest.freespec.AnyFreeSpec
56
import io.iohk.ethereum.domain.UInt256
67

78
// scalastyle:off magic.number
8-
class FibonacciSpec extends FreeSpec with Matchers {
9+
class FibonacciSpec extends AnyFreeSpec with Matchers {
910

1011
"EVM running Fibonacci contract" - {
1112

src/evmTest/scala/io/iohk/ethereum/vm/MinimumViableTokenSpec.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
54
import io.iohk.ethereum.domain.UInt256
5+
import org.scalatest.matchers.should.Matchers
6+
import org.scalatest.freespec.AnyFreeSpec
67

78
// scalastyle:off magic.number
8-
class MinimumViableTokenSpec extends FreeSpec with Matchers {
9+
class MinimumViableTokenSpec extends AnyFreeSpec with Matchers {
910

1011
"EVM running MinimumViableToken contract" - {
1112

@@ -38,8 +39,8 @@ class MinimumViableTokenSpec extends FreeSpec with Matchers {
3839
val sender = createAccount(balance = 10)
3940
val receiver = createAccount(balance = 10)
4041

41-
val (result, _) = deployContract("MinimumViableToken", creatorAddress = sender,
42-
constructorArgs = Seq(100), gasLimit = 102934)
42+
val (result, _) =
43+
deployContract("MinimumViableToken", creatorAddress = sender, constructorArgs = Seq(100), gasLimit = 102934)
4344

4445
result.error shouldBe Some(OutOfGas)
4546
}

src/evmTest/scala/io/iohk/ethereum/vm/MutualRecursionSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
54
import io.iohk.ethereum.domain.UInt256
5+
import org.scalatest.freespec.AnyFreeSpec
6+
import org.scalatest.matchers.should.Matchers
67

78
// scalastyle:off magic.number
8-
class MutualRecursionSpec extends FreeSpec with Matchers {
9+
class MutualRecursionSpec extends AnyFreeSpec with Matchers {
910

1011
"EVM running MutualRecursion contract" - {
1112

src/evmTest/scala/io/iohk/ethereum/vm/PrecompiledContractsSpecEvm.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import io.iohk.ethereum.crypto._
66
import io.iohk.ethereum.domain.SignedTransaction.{FirstByteOfAddress, LastByteOfAddress}
77
import io.iohk.ethereum.nodebuilder.SecureRandomBuilder
88
import io.iohk.ethereum.vm.utils.EvmTestEnv
9-
import org.scalatest.{FunSuite, Matchers}
109
import org.bouncycastle.crypto.params.ECPublicKeyParameters
10+
import org.scalatest.funsuite.AnyFunSuite
11+
import org.scalatest.matchers.should.Matchers
1112

12-
class PrecompiledContractsSpecEvm extends FunSuite with Matchers with SecureRandomBuilder {
13+
class PrecompiledContractsSpecEvm extends AnyFunSuite with Matchers with SecureRandomBuilder {
1314

1415
test("Precompiled Contracts") {
1516
val keyPair = generateKeyPair(secureRandom)

src/evmTest/scala/io/iohk/ethereum/vm/ThrowSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package io.iohk.ethereum.vm
22

33
import io.iohk.ethereum.vm.utils.EvmTestEnv
4-
import org.scalatest.{FreeSpec, Matchers}
4+
import org.scalatest.freespec.AnyFreeSpec
5+
import org.scalatest.matchers.should.Matchers
56

67
// scalastyle:off magic.number
7-
class ThrowSpec extends FreeSpec with Matchers {
8+
class ThrowSpec extends AnyFreeSpec with Matchers {
89

910
"EVM running Throw contract" - {
1011

src/it/scala/io/iohk/ethereum/db/DataSourceIntegrationTestBehavior.scala

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ package io.iohk.ethereum.db
22

33
import java.io.File
44
import java.nio.file.Files
5+
56
import akka.util.ByteString
67
import io.iohk.ethereum.ObjectGenerators
78
import io.iohk.ethereum.db.dataSource.{DataSource, DataSourceUpdate}
89
import io.iohk.ethereum.db.dataSource.DataSource.{Key, Namespace, Value}
9-
import org.scalatest.FlatSpec
10+
import org.scalatest.flatspec.AnyFlatSpec
1011
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
1112

1213
trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with ObjectGenerators {
1314

14-
this: FlatSpec =>
15+
this: AnyFlatSpec =>
1516

1617
val KeySizeWithoutPrefix: Int = 32
1718
val KeySize: Int = KeySizeWithoutPrefix + 1
@@ -32,15 +33,15 @@ trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with Ob
3233
}
3334

3435
def prepareUpdate(
35-
namespace: Namespace = OtherNamespace,
36-
toRemove: Seq[Key] = Nil,
37-
toUpsert: Seq[(Key, Value)] = Nil
36+
namespace: Namespace = OtherNamespace,
37+
toRemove: Seq[Key] = Nil,
38+
toUpsert: Seq[(Key, Value)] = Nil
3839
): Seq[DataSourceUpdate] =
3940
Seq(DataSourceUpdate(namespace, toRemove, toUpsert))
4041

4142
def updateInSeparateCalls(
42-
dataSource: DataSource,
43-
toUpsert: Seq[(ByteString, ByteString)]
43+
dataSource: DataSource,
44+
toUpsert: Seq[(ByteString, ByteString)]
4445
): Unit = {
4546
toUpsert.foreach { keyValuePair =>
4647
dataSource.update(prepareUpdate(toUpsert = Seq(keyValuePair)))
@@ -93,9 +94,8 @@ trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with Ob
9394
val keyListWithExtraByte = keyList.map(1.toByte +: _)
9495
updateInSeparateCalls(db, keyList.zip(keyListWithExtraByte))
9596

96-
keyList.zip(keyListWithExtraByte).foreach {
97-
case (key, value) =>
98-
assert(db.get(OtherNamespace, key).contains(value))
97+
keyList.zip(keyListWithExtraByte).foreach { case (key, value) =>
98+
assert(db.get(OtherNamespace, key).contains(value))
9999
}
100100

101101
db.destroy()
@@ -113,9 +113,8 @@ trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with Ob
113113
val keyListWithExtraByte = keyList.map(1.toByte +: _)
114114
db.update(prepareUpdate(toUpsert = keyList.zip(keyListWithExtraByte)))
115115

116-
keyList.zip(keyListWithExtraByte).foreach {
117-
case (key, value) =>
118-
assert(db.get(OtherNamespace, key).contains(value))
116+
keyList.zip(keyListWithExtraByte).foreach { case (key, value) =>
117+
assert(db.get(OtherNamespace, key).contains(value))
119118
}
120119

121120
db.destroy()
@@ -191,9 +190,8 @@ trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with Ob
191190
val valList2 = keyList.map(2.toByte +: _)
192191
db.update(prepareUpdate(namespace = OtherNamespace2, toUpsert = keyList.zip(valList2)))
193192

194-
keyList.zip(valList1).foreach {
195-
case (key, value) =>
196-
assert(db.get(OtherNamespace, key).contains(value))
193+
keyList.zip(valList1).foreach { case (key, value) =>
194+
assert(db.get(OtherNamespace, key).contains(value))
197195
}
198196
keyList.zip(valList2).foreach { case (key, value) =>
199197
assert(db.get(OtherNamespace2, key).contains(value))
@@ -223,9 +221,8 @@ trait DataSourceIntegrationTestBehavior extends ScalaCheckPropertyChecks with Ob
223221
keyList.foreach { key =>
224222
assert(db.get(OtherNamespace, key).isEmpty)
225223
}
226-
keyList.zip(valList2).foreach {
227-
case (key, value) =>
228-
assert(db.get(OtherNamespace2, key).contains(value))
224+
keyList.zip(valList2).foreach { case (key, value) =>
225+
assert(db.get(OtherNamespace2, key).contains(value))
229226
}
230227

231228
//Removal of keys from the OtherNamespace2 namespace

src/it/scala/io/iohk/ethereum/db/RocksDbDataSourceIntegrationSuite.scala

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ package io.iohk.ethereum.db
22

33
import io.iohk.ethereum.db.dataSource.{RocksDbConfig, RocksDbDataSource}
44
import io.iohk.ethereum.db.storage.Namespaces
5-
import org.scalatest.FlatSpec
5+
import org.scalatest.flatspec.AnyFlatSpec
66

7-
class RocksDbDataSourceIntegrationSuite extends FlatSpec with DataSourceIntegrationTestBehavior {
7+
class RocksDbDataSourceIntegrationSuite extends AnyFlatSpec with DataSourceIntegrationTestBehavior {
88

9-
private def createDataSource(dataSourcePath: String) = RocksDbDataSource(new RocksDbConfig {
10-
override val createIfMissing: Boolean = true
11-
override val paranoidChecks: Boolean = true
12-
override val path: String = dataSourcePath
13-
override val maxThreads: Int = 1
14-
override val maxOpenFiles: Int = 32
15-
override val verifyChecksums: Boolean = true
16-
override val levelCompaction: Boolean = true
17-
override val blockSize: Long = 16384
18-
override val blockCacheSize: Long = 33554432
19-
}, Namespaces.nsSeq)
9+
private def createDataSource(dataSourcePath: String) = RocksDbDataSource(
10+
new RocksDbConfig {
11+
override val createIfMissing: Boolean = true
12+
override val paranoidChecks: Boolean = true
13+
override val path: String = dataSourcePath
14+
override val maxThreads: Int = 1
15+
override val maxOpenFiles: Int = 32
16+
override val verifyChecksums: Boolean = true
17+
override val levelCompaction: Boolean = true
18+
override val blockSize: Long = 16384
19+
override val blockCacheSize: Long = 33554432
20+
},
21+
Namespaces.nsSeq
22+
)
2023

2124
it should behave like dataSource(createDataSource)
2225
}
23-

0 commit comments

Comments
 (0)