-
Notifications
You must be signed in to change notification settings - Fork 75
ETCM 944 Extract instantiation of InMemoryWorldStateProxy from Blockchain class #1025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
leo-bogastry
merged 6 commits into
develop
from
refactor/ETCM-944-InMemoryWorldStateProxy
Jun 28, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bc917c
ETCM-944 - Refactoring - extract methods getWorldStateProxy and getRe…
2678ffb
ETCM-944 Rename test class to SchedulerStateSpec
671578a
ETCM-944 Fix tests
52d1b3c
ETCM-944 Pass getBlockHashByNumber field directly to InMemoryWorldSta…
ce5fe8c
ETCM-944 Rollback min-peers-to-choose-pivor-block to 3
11c05a1
ETCM-944 Rename some methods
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
57 changes: 17 additions & 40 deletions
57
src/it/scala/io/iohk/ethereum/txExecTest/ContractTest.scala
This file contains hidden or 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 |
---|---|---|
@@ -1,64 +1,41 @@ | ||
package io.iohk.ethereum.txExecTest | ||
|
||
import java.util.concurrent.Executors | ||
|
||
import io.iohk.ethereum.domain.Receipt | ||
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation, Ledger} | ||
import io.iohk.ethereum.domain.{BlockchainImpl, Receipt} | ||
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation} | ||
import io.iohk.ethereum.txExecTest.util.FixtureProvider | ||
import io.iohk.ethereum.utils.Config | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
class ContractTest extends AnyFlatSpec with Matchers { | ||
val blockchainConfig = Config.blockchains.blockchainConfig | ||
val syncConfig = Config.SyncConfig(Config.config) | ||
val vm = new Ledger.VMImpl | ||
val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(4)) | ||
val noErrors = a[Right[_, Seq[Receipt]]] | ||
|
||
"Ledger" should "transfer ether" in new ScenarioSetup { | ||
"Ledger" should "execute and validate" in new ScenarioSetup { | ||
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract") | ||
lazy val testBlockchainStorages = FixtureProvider.prepareStorages(2, fixtures) | ||
|
||
val testBlockchainStorages = FixtureProvider.prepareStorages(0, fixtures) | ||
override lazy val blockchain = BlockchainImpl(testBlockchainStorages) | ||
|
||
//block only with ether transfers | ||
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig)) | ||
val blockExecution = new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation) | ||
val blockExecution = new BlockExecution( | ||
blockchain, | ||
testBlockchainStorages.evmCodeStorage, | ||
blockchainConfig, | ||
consensus.blockPreparator, | ||
blockValidation | ||
) | ||
|
||
// transfer ether | ||
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(1)) shouldBe noErrors | ||
} | ||
|
||
it should "deploy contract" in new ScenarioSetup { | ||
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract") | ||
|
||
val testBlockchainStorages = FixtureProvider.prepareStorages(1, fixtures) | ||
|
||
//contract creation | ||
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig)) | ||
val blockExecution = new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation) | ||
// deploy contract | ||
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(2)) shouldBe noErrors | ||
} | ||
|
||
it should "execute contract call" in new ScenarioSetup { | ||
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract") | ||
|
||
val testBlockchainStorages = FixtureProvider.prepareStorages(2, fixtures) | ||
|
||
//block with ether transfers and contract call | ||
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig)) | ||
val blockExecution = new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation) | ||
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(3)) shouldBe noErrors | ||
} | ||
|
||
it should "execute contract that pays 2 accounts" in new ScenarioSetup { | ||
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract") | ||
|
||
val testBlockchainStorages = FixtureProvider.prepareStorages(2, fixtures) | ||
|
||
//block contains contract paying 2 accounts | ||
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig)) | ||
val blockExecution = new BlockExecution(blockchain, blockchainConfig, consensus.blockPreparator, blockValidation) | ||
// execute contract call | ||
// execute contract that pays 2 accounts | ||
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(3)) shouldBe noErrors | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package io.iohk.ethereum.txExecTest | ||
|
||
import io.iohk.ethereum.blockchain.sync | ||
import io.iohk.ethereum.blockchain.sync.EphemBlockchainTestSetup | ||
import io.iohk.ethereum.domain.{BlockchainImpl, BlockchainStorages} | ||
import io.iohk.ethereum.ledger.Ledger.VMImpl | ||
|
||
trait ScenarioSetup extends sync.ScenarioSetup { | ||
trait ScenarioSetup extends EphemBlockchainTestSetup { | ||
protected val testBlockchainStorages: BlockchainStorages | ||
|
||
override lazy val blockchain: BlockchainImpl = BlockchainImpl(testBlockchainStorages) | ||
override lazy val vm: VMImpl = new VMImpl | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.