Skip to content

Commit f627900

Browse files
author
Aurélien Richez
committed
scalafmt
1 parent 43c6973 commit f627900

12 files changed

+102
-50
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class BlockBroadcastSpec
3232
NewBlock(Block(blockHeader, BlockBody(Nil, Nil)), initialPeerInfo.chainWeight.increaseTotalDifficulty(2))
3333

3434
//when
35-
blockBroadcast.broadcastBlock(BlockToBroadcast(newBlock.block, newBlock.chainWeight), Map(peer.id -> PeerWithInfo(peer, initialPeerInfo)))
35+
blockBroadcast.broadcastBlock(
36+
BlockToBroadcast(newBlock.block, newBlock.chainWeight),
37+
Map(peer.id -> PeerWithInfo(peer, initialPeerInfo))
38+
)
3639

3740
//then
3841
etcPeerManagerProbe.expectMsg(EtcPeerManagerActor.SendMessage(newBlock, peer.id))
@@ -71,7 +74,10 @@ class BlockBroadcastSpec
7174
NewBlock(Block(blockHeader, BlockBody(Nil, Nil)), initialPeerInfo.chainWeight.increaseTotalDifficulty(-2))
7275

7376
//when
74-
blockBroadcast.broadcastBlock(BlockToBroadcast(newBlock.block, newBlock.chainWeight), Map(peer.id -> PeerWithInfo(peer, initialPeerInfo)))
77+
blockBroadcast.broadcastBlock(
78+
BlockToBroadcast(newBlock.block, newBlock.chainWeight),
79+
Map(peer.id -> PeerWithInfo(peer, initialPeerInfo))
80+
)
7581

7682
//then
7783
etcPeerManagerProbe.expectNoMessage()
@@ -85,7 +91,10 @@ class BlockBroadcastSpec
8591
NewBlock(Block(blockHeader, BlockBody(Nil, Nil)), initialPeerInfo.chainWeight.increaseTotalDifficulty(-2))
8692

8793
//when
88-
blockBroadcast.broadcastBlock(BlockToBroadcast(newBlock.block, newBlock.chainWeight), Map(peer.id -> PeerWithInfo(peer, initialPeerInfo)))
94+
blockBroadcast.broadcastBlock(
95+
BlockToBroadcast(newBlock.block, newBlock.chainWeight),
96+
Map(peer.id -> PeerWithInfo(peer, initialPeerInfo))
97+
)
8998

9099
//then
91100
etcPeerManagerProbe.expectMsg(EtcPeerManagerActor.SendMessage(newBlock, peer.id))
@@ -101,7 +110,10 @@ class BlockBroadcastSpec
101110
NewBlock(Block(blockHeader, BlockBody(Nil, Nil)), initialPeerInfo.chainWeight.increaseTotalDifficulty(-2))
102111

103112
//when
104-
blockBroadcast.broadcastBlock(BlockToBroadcast(newBlock.block, newBlock.chainWeight), Map(peer.id -> PeerWithInfo(peer, initialPeerInfo)))
113+
blockBroadcast.broadcastBlock(
114+
BlockToBroadcast(newBlock.block, newBlock.chainWeight),
115+
Map(peer.id -> PeerWithInfo(peer, initialPeerInfo))
116+
)
105117

106118
//then
107119
etcPeerManagerProbe.expectNoMessage()

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ class PeersClientSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyC
3131
"Single peer"
3232
),
3333
(
34-
Map(peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100, fork = false)), peer2.id -> PeerWithInfo(peer2, peerInfo(0, 50, fork = true))),
34+
Map(
35+
peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100, fork = false)),
36+
peer2.id -> PeerWithInfo(peer2, peerInfo(0, 50, fork = true))
37+
),
3538
Some(peer2),
3639
"Peer2 with lower TD but following the ETC fork"
3740
),
@@ -41,12 +44,20 @@ class PeersClientSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyC
4144
"Peer2 with higher TD"
4245
),
4346
(
44-
Map(peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100)), peer2.id -> PeerWithInfo(peer2, peerInfo(0, 101)), peer3.id -> PeerWithInfo(peer3, peerInfo(1, 50))),
47+
Map(
48+
peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100)),
49+
peer2.id -> PeerWithInfo(peer2, peerInfo(0, 101)),
50+
peer3.id -> PeerWithInfo(peer3, peerInfo(1, 50))
51+
),
4552
Some(peer3),
4653
"Peer3 with lower TD but higher checkpoint number"
4754
),
4855
(
49-
Map(peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100)), peer2.id -> PeerWithInfo(peer2, peerInfo(4, 101)), peer3.id -> PeerWithInfo(peer3, peerInfo(4, 50))),
56+
Map(
57+
peer1.id -> PeerWithInfo(peer1, peerInfo(0, 100)),
58+
peer2.id -> PeerWithInfo(peer2, peerInfo(4, 101)),
59+
peer3.id -> PeerWithInfo(peer3, peerInfo(4, 50))
60+
),
5061
Some(peer2),
5162
"Peer2 with equal checkpoint number and higher TD"
5263
)

src/test/scala/io/iohk/ethereum/blockchain/sync/fast/FastSyncBranchResolverActorSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ class FastSyncBranchResolverActorSpec
264264
)
265265
}
266266

267-
val handshakedPeers: Map[Peer, PeerInfo] = (0 to 5).toList.map((peerId _).andThen(getPeer)).fproduct(getPeerInfo(_)).toMap
267+
val handshakedPeers: Map[Peer, PeerInfo] =
268+
(0 to 5).toList.map((peerId _).andThen(getPeer)).fproduct(getPeerInfo(_)).toMap
268269

269270
def saveBlocks(blocks: List[Block]): Unit = {
270271
blocks.foreach(block => blockchain.save(block, Nil, ChainWeight.totalDifficultyOnly(1), saveAsBestBlock = true))

src/test/scala/io/iohk/ethereum/blockchain/sync/regular/BlockFetcherSpec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ class BlockFetcherSpec extends ScalaTestWithActorTestKit() with AnyFreeSpecLike
9999
peersClient.expectNoMessage()
100100

101101
// Failure of the second request should make the fetcher resume with his requests
102-
peersClient.send(refExpectingReply, PeersClient.RequestFailed(fakePeer, BlacklistReason.RegularSyncRequestFailed("")))
102+
peersClient.send(
103+
refExpectingReply,
104+
PeersClient.RequestFailed(fakePeer, BlacklistReason.RegularSyncRequestFailed(""))
105+
)
103106

104107
peersClient.expectMsgClass(classOf[BlacklistPeer])
105108
peersClient.expectMsgPF() { case PeersClient.Request(msg, _, _) if msg == firstGetBlockHeadersRequest => () }

src/test/scala/io/iohk/ethereum/blockchain/sync/regular/RegularSyncFixtures.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ trait RegularSyncFixtures { self: Matchers with AsyncMockFactory =>
4949
implicit override lazy val system: ActorSystem = _system
5050
override lazy val syncConfig: SyncConfig =
5151
defaultSyncConfig.copy(blockHeadersPerRequest = 2, blockBodiesPerRequest = 2)
52-
val handshakedPeers: Map[Peer, PeerInfo] = (0 to 5).toList.map((peerId _).andThen(getPeer)).fproduct(getPeerInfo(_)).toMap
52+
val handshakedPeers: Map[Peer, PeerInfo] =
53+
(0 to 5).toList.map((peerId _).andThen(getPeer)).fproduct(getPeerInfo(_)).toMap
5354
val defaultPeer: Peer = peerByNumber(0)
5455

5556
val etcPeerManager: TestProbe = TestProbe()

src/test/scala/io/iohk/ethereum/blockchain/sync/regular/RegularSyncSpec.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ class RegularSyncSpec
111111
regularSync ! SyncProtocol.Start
112112

113113
peersClient.expectMsgType[PeersClient.Request[GetBlockHeaders]]
114-
peersClient.reply(PeersClient.RequestFailed(defaultPeer, BlacklistReason.RegularSyncRequestFailed("a random reason")))
115-
peersClient.expectMsg(PeersClient.BlacklistPeer(defaultPeer.id, BlacklistReason.RegularSyncRequestFailed("a random reason")))
114+
peersClient.reply(
115+
PeersClient.RequestFailed(defaultPeer, BlacklistReason.RegularSyncRequestFailed("a random reason"))
116+
)
117+
peersClient.expectMsg(
118+
PeersClient.BlacklistPeer(defaultPeer.id, BlacklistReason.RegularSyncRequestFailed("a random reason"))
119+
)
116120
})
117121

118122
"blacklist peer which returns headers starting from one with higher number than expected" in sync(

src/test/scala/io/iohk/ethereum/consensus/blocks/BlockGeneratorSpec.scala

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
239239
ecip1097BlockNumber = Long.MaxValue,
240240
ecip1099BlockNumber = Long.MaxValue,
241241
ecip1049BlockNumber = None
242-
),
243-
242+
)
244243
)
245244

246245
override lazy val blockExecution =
@@ -521,7 +520,8 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
521520
_.copy(
522521
ecip1098BlockNumber = 1000,
523522
ecip1097BlockNumber = 2000
524-
))
523+
)
524+
)
525525

526526
override lazy val consensusConfig = buildConsensusConfig()
527527
}
@@ -544,12 +544,16 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
544544

545545
it should "generate a failure if treasury transfer was not made" in {
546546
val producer = new TestSetup {
547-
override lazy val blockchainConfig = baseBlockchainConfig.withUpdatedForkBlocks(_.copy(
548-
ecip1098BlockNumber = 20000000,
549-
)).copy(
550-
treasuryAddress = treasuryAccount,
551-
customGenesisFileOpt = Some("test-genesis-treasury.json")
552-
)
547+
override lazy val blockchainConfig = baseBlockchainConfig
548+
.withUpdatedForkBlocks(
549+
_.copy(
550+
ecip1098BlockNumber = 20000000
551+
)
552+
)
553+
.copy(
554+
treasuryAddress = treasuryAccount,
555+
customGenesisFileOpt = Some("test-genesis-treasury.json")
556+
)
553557
override lazy val consensusConfig = buildConsensusConfig()
554558
}
555559
val block = {
@@ -563,9 +567,9 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
563567
override lazy val blockchainConfig = baseBlockchainConfig
564568
.withUpdatedForkBlocks(_.copy(ecip1098BlockNumber = 1))
565569
.copy(
566-
treasuryAddress = treasuryAccount,
567-
customGenesisFileOpt = Some("test-genesis-treasury.json")
568-
)
570+
treasuryAddress = treasuryAccount,
571+
customGenesisFileOpt = Some("test-genesis-treasury.json")
572+
)
569573
override lazy val consensusConfig = buildConsensusConfig()
570574
}
571575

@@ -584,10 +588,11 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
584588
it should "generate a failure if treasury transfer was made to a different treasury account" in {
585589
val producer = new TestSetup {
586590
override lazy val blockchainConfig = baseBlockchainConfig
587-
.withUpdatedForkBlocks(_.copy(ecip1098BlockNumber = 1)).copy(
588-
treasuryAddress = maliciousAccount,
589-
customGenesisFileOpt = Some("test-genesis-treasury.json")
590-
)
591+
.withUpdatedForkBlocks(_.copy(ecip1098BlockNumber = 1))
592+
.copy(
593+
treasuryAddress = maliciousAccount,
594+
customGenesisFileOpt = Some("test-genesis-treasury.json")
595+
)
591596
override lazy val consensusConfig = buildConsensusConfig()
592597
}
593598
val block = {
@@ -601,9 +606,9 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
601606
override lazy val blockchainConfig = baseBlockchainConfig
602607
.withUpdatedForkBlocks(_.copy(ecip1098BlockNumber = 1))
603608
.copy(
604-
treasuryAddress = treasuryAccount,
605-
customGenesisFileOpt = Some("test-genesis-treasury.json")
606-
)
609+
treasuryAddress = treasuryAccount,
610+
customGenesisFileOpt = Some("test-genesis-treasury.json")
611+
)
607612
override lazy val consensusConfig = buildConsensusConfig()
608613
}
609614

@@ -682,7 +687,7 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
682687
bootstrapNodes = Set(),
683688
gasTieBreaker = false,
684689
ethCompatibleStorage = true,
685-
treasuryAddress = Address(0),
690+
treasuryAddress = Address(0)
686691
)
687692
override lazy val blockchainConfig = baseBlockchainConfig
688693

src/test/scala/io/iohk/ethereum/consensus/pow/validators/RestrictedEthashBlockHeaderValidatorSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class RestrictedEthashBlockHeaderValidatorSpec
105105
ethCompatibleStorage = true,
106106
treasuryAddress = Address(0),
107107
checkpointPubKeys = Set.empty,
108-
allowedMinersPublicKeys = allowedMiners,
108+
allowedMinersPublicKeys = allowedMiners
109109
)
110110
}
111111

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ class BlockWithCheckpointHeaderValidatorSpec
130130
}
131131

132132
it should "return failure if created based on invalid number" in new TestSetup {
133-
forAll(longGen suchThat (num => num != validBlockParentHeader.number + 1 && num >= config.forkBlockNumbers.ecip1097BlockNumber)) {
134-
number =>
135-
val blockHeader = validBlockHeaderWithCheckpoint.copy(number = number)
136-
val validateResult = blockHeaderValidator.validate(blockHeader, validBlockParentHeader)
137-
assert(validateResult == Left(HeaderNumberError))
133+
forAll(
134+
longGen suchThat (num =>
135+
num != validBlockParentHeader.number + 1 && num >= config.forkBlockNumbers.ecip1097BlockNumber
136+
)
137+
) { number =>
138+
val blockHeader = validBlockHeaderWithCheckpoint.copy(number = number)
139+
val validateResult = blockHeaderValidator.validate(blockHeader, validBlockParentHeader)
140+
assert(validateResult == Left(HeaderNumberError))
138141
}
139142
}
140143

@@ -257,13 +260,17 @@ class BlockWithCheckpointHeaderValidatorSpec
257260
"6848a3ab71918f57d3b9116b8e93c6fbc53e8a28dcd63e99c514dceee30fdd9741050fa7646bd196c9512e52f0d03097678c707996fff55587cd467801a1eee1"
258261
)
259262
)
260-
val config: BlockchainConfig = blockchainConfig.withUpdatedForkBlocks(_.copy(
261-
ecip1097BlockNumber = validBlockParentHeader.number,
262-
ecip1098BlockNumber = validBlockParentHeader.number,
263-
eip106BlockNumber = 0,
264-
)).copy(
265-
checkpointPubKeys = checkpointPubKeys
266-
)
263+
val config: BlockchainConfig = blockchainConfig
264+
.withUpdatedForkBlocks(
265+
_.copy(
266+
ecip1097BlockNumber = validBlockParentHeader.number,
267+
ecip1098BlockNumber = validBlockParentHeader.number,
268+
eip106BlockNumber = 0
269+
)
270+
)
271+
.copy(
272+
checkpointPubKeys = checkpointPubKeys
273+
)
267274

268275
val keys = Seq(
269276
crypto.keyPairFromPrvKey(

src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class PersonalServiceSpec
431431
bootstrapNodes = Set(),
432432
gasTieBreaker = false,
433433
ethCompatibleStorage = true,
434-
treasuryAddress = Address(0),
434+
treasuryAddress = Address(0)
435435
)
436436

437437
val wallet = Wallet(address, prvKey)

src/test/scala/io/iohk/ethereum/ledger/BlockPreparatorSpec.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class BlockPreparatorSpec extends AnyWordSpec with Matchers with ScalaCheckPrope
8686
payload = ByteString.empty
8787
)
8888
val stx: SignedTransactionWithSender = SignedTransaction.sign(tx, originKeyPair, Some(blockchainConfig.chainId))
89-
val header: BlockHeader = defaultBlockHeader.copy(number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber - 1)
89+
val header: BlockHeader =
90+
defaultBlockHeader.copy(number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber - 1)
9091

9192
val result: Either[BlockExecutionError.TxsExecutionError, BlockResult] =
9293
consensus.blockPreparator.executeTransactions(Seq(stx.tx), initialWorld, header)
@@ -107,7 +108,10 @@ class BlockPreparatorSpec extends AnyWordSpec with Matchers with ScalaCheckPrope
107108
)
108109
val stx: SignedTransaction = SignedTransaction.sign(tx, originKeyPair, Some(blockchainConfig.chainId)).tx
109110
val header: BlockHeader =
110-
defaultBlockHeader.copy(beneficiary = minerAddress.bytes, number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber)
111+
defaultBlockHeader.copy(
112+
beneficiary = minerAddress.bytes,
113+
number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber
114+
)
111115

112116
val result: Either[BlockExecutionError.TxsExecutionError, BlockResult] =
113117
consensus.blockPreparator.executeTransactions(Seq(stx), initialWorld, header)
@@ -133,7 +137,10 @@ class BlockPreparatorSpec extends AnyWordSpec with Matchers with ScalaCheckPrope
133137
)
134138
val stx: SignedTransactionWithSender = SignedTransaction.sign(tx, originKeyPair, Some(blockchainConfig.chainId))
135139
val header: BlockHeader =
136-
defaultBlockHeader.copy(beneficiary = minerAddress.bytes, number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber)
140+
defaultBlockHeader.copy(
141+
beneficiary = minerAddress.bytes,
142+
number = blockchainConfig.forkBlockNumbers.byzantiumBlockNumber
143+
)
137144

138145
val result: Either[BlockExecutionError.TxsExecutionError, BlockResult] =
139146
testConsensus.blockPreparator.executeTransactions(Seq(stx.tx), initialWorld, header)

src/test/scala/io/iohk/ethereum/ledger/BlockRewardSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyC
181181
val baseBlockchainConfig = Config.blockchains.blockchainConfig
182182
private val forkBlockNumbers: ForkBlockNumbers = baseBlockchainConfig.forkBlockNumbers
183183
override lazy val blockchainConfig = baseBlockchainConfig
184-
.copy(treasuryAddress = treasuryAddress,
184+
.copy(
185+
treasuryAddress = treasuryAddress,
185186
forkBlockNumbers = forkBlockNumbers
186187
.copy(ecip1098BlockNumber = forkBlockNumbers.byzantiumBlockNumber + 100)
187188
)

0 commit comments

Comments
 (0)