forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added parameterized tests to test Bonsai And Forest (hyperledger#2131)
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
- Loading branch information
Showing
14 changed files
with
414 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 44 additions & 82 deletions
126
...eth/sync/BlockPropagationManagerTest.java → .../AbstractBlockPropagationManagerTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...c/test/java/org/hyperledger/besu/ethereum/eth/sync/BonsaiBlockPropagationManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.eth.sync; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; | ||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; | ||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; | ||
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; | ||
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; | ||
|
||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
|
||
public class BonsaiBlockPropagationManagerTest extends AbstractBlockPropagationManagerTest { | ||
|
||
private static Blockchain fullBlockchain; | ||
|
||
@BeforeClass | ||
public static void setupSuite() { | ||
fullBlockchain = BlockchainSetupUtil.forTesting(DataStorageFormat.BONSAI).importAllBlocks(); | ||
} | ||
|
||
@Before | ||
public void setup() { | ||
blockchainUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.BONSAI); | ||
blockchain = blockchainUtil.getBlockchain(); | ||
protocolSchedule = blockchainUtil.getProtocolSchedule(); | ||
final ProtocolContext tempProtocolContext = blockchainUtil.getProtocolContext(); | ||
protocolContext = | ||
new ProtocolContext( | ||
blockchain, | ||
tempProtocolContext.getWorldStateArchive(), | ||
tempProtocolContext.getConsensusState(Object.class)); | ||
ethProtocolManager = | ||
EthProtocolManagerTestUtil.create( | ||
blockchain, | ||
blockchainUtil.getWorldArchive(), | ||
blockchainUtil.getTransactionPool(), | ||
EthProtocolConfiguration.defaultConfig()); | ||
syncConfig = SynchronizerConfiguration.builder().blockPropagationRange(-3, 5).build(); | ||
syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); | ||
blockBroadcaster = mock(BlockBroadcaster.class); | ||
blockPropagationManager = | ||
new BlockPropagationManager( | ||
syncConfig, | ||
protocolSchedule, | ||
protocolContext, | ||
ethProtocolManager.ethContext(), | ||
syncState, | ||
pendingBlocksManager, | ||
metricsSystem, | ||
blockBroadcaster); | ||
} | ||
|
||
@Override | ||
public Blockchain getFullBlockchain() { | ||
return fullBlockchain; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...c/test/java/org/hyperledger/besu/ethereum/eth/sync/ForestBlockPropagationManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.eth.sync; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; | ||
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; | ||
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; | ||
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; | ||
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; | ||
|
||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
|
||
public class ForestBlockPropagationManagerTest extends AbstractBlockPropagationManagerTest { | ||
|
||
private static Blockchain fullBlockchain; | ||
|
||
@BeforeClass | ||
public static void setupSuite() { | ||
fullBlockchain = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST).importAllBlocks(); | ||
} | ||
|
||
@Before | ||
public void setup() { | ||
blockchainUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); | ||
blockchain = blockchainUtil.getBlockchain(); | ||
protocolSchedule = blockchainUtil.getProtocolSchedule(); | ||
final ProtocolContext tempProtocolContext = blockchainUtil.getProtocolContext(); | ||
protocolContext = | ||
new ProtocolContext( | ||
blockchain, | ||
tempProtocolContext.getWorldStateArchive(), | ||
tempProtocolContext.getConsensusState(Object.class)); | ||
ethProtocolManager = | ||
EthProtocolManagerTestUtil.create( | ||
blockchain, | ||
blockchainUtil.getWorldArchive(), | ||
blockchainUtil.getTransactionPool(), | ||
EthProtocolConfiguration.defaultConfig()); | ||
syncConfig = SynchronizerConfiguration.builder().blockPropagationRange(-3, 5).build(); | ||
syncState = new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers()); | ||
blockBroadcaster = mock(BlockBroadcaster.class); | ||
blockPropagationManager = | ||
new BlockPropagationManager( | ||
syncConfig, | ||
protocolSchedule, | ||
protocolContext, | ||
ethProtocolManager.ethContext(), | ||
syncState, | ||
pendingBlocksManager, | ||
metricsSystem, | ||
blockBroadcaster); | ||
} | ||
|
||
@Override | ||
public Blockchain getFullBlockchain() { | ||
return fullBlockchain; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.