Updater unit tests#6913
Conversation
|
It looks like @lght hasn'signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, plesae reply to this thread with Many thanks, Parity Technologies CLA Bot |
|
why commits from @arkpar are included in this pr? |
|
[clabot:check] |
|
It looks like @lght signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
|
@NikVolf I know, I tried to roll back to master before that contribution. Still not sure how the two commits got rolled up together. Any recs to detangle that commit? |
|
just merge latest master, reset soft to it, then add, commit and force push |
|
oh a since it's a fork, make sure your master is the same as paritytech::master |
Signed-off-by: lght <cole@parity.io>
95a19f1 to
0083982
Compare
|
woot! that worked, thanks so much :) 👍 |
Signed-off-by: lght <cole@parity.io>
Signed-off-by: lght <cole@parity.io>
Signed-off-by: lght <cole@parity.io>
| } | ||
| } | ||
|
|
||
| pub struct NoopDBRestore; |
There was a problem hiding this comment.
just saw this. added doc comments to that struct and the following trait.
was planning to move the split-out test classes shared across crates to a central parity-test crate. think this would be a worthwhile change, but wanted to consult the team before starting in on the work. what are your thoughts on taking this approach?
Signed-off-by: lght <cole@parity.io>
Signed-off-by: lght <cole@parity.io>
First steps to implementing calling into the local Operations contract from TestBlockChainClient Signed-off-by: lght <cole@parity.io>
Signed-off-by: lght <cole@parity.io> [fix] UpdaterState set in test constructor, tests::info passes Signed-off-by: lght <cole@parity.io> [fix] All unit tests passing, using kvdb_memory-backed blockchain Signed-off-by: lght <cole@parity.io> [minor fix] corrected path to test helper Signed-off-by: lght <cole@parity.io> [minor fixes] dependency refactors and new Spec::new_test_kovan() Signed-off-by: lght <cole@parity.io> [minor fix] ethcore::snapshot::account test dependency fix Signed-off-by: lght <cole@parity.io> [fix] Dependency issue finally fixed Signed-off-by: lght <cole@parity.io>
967399c to
eb9da9b
Compare
Signed-off-by: lght <cole@parity.io>
b2ff878 to
b55d5c5
Compare
Operations.sol and derived files under updater/res were added accidentally, and only used for local analysis purposes. Signed-off-by: lght <cole@parity.io>
|
9 tests failed. |
|
Yeah, I noticed that too. 👎 Those are all tests for rpc, which are not part of this PR. Think those errors came over from a merge with master. ~~~If those tests are fixed in main, I can pull down the changes and merge with this PR.~~~ Pulled down the latest master, and this problem still exists. From latest CI run: |
| // against a real testnet. | ||
|
|
||
| //#[test] | ||
| //fn operations_call_clients_required() { |
| return; | ||
| } | ||
| } | ||
| if self.operations.lock().is_none() { |
| manifest: Option<ManifestData>, | ||
| chunks: HashMap<H256, Bytes>, | ||
|
|
||
| restoration_manifest: Mutex<Option<ManifestData>>, |
There was a problem hiding this comment.
Might be simple to have a:
struct Wrapped(Mutex<TestSnapshotService>);
impl SnapshotService for Wrapped {
}
instead of maintaining all those Mutexes/locks here.
There was a problem hiding this comment.
That would be simpler. ~~~Since this PR is already fairly large, can we save that change for another PR to refactor TestSnapshotSevice?~~~ Going to put my focus into refactoring TestSnapshotService to merge this PR as quickly as possible since it is holding #6896.
There are a number of refactors that will need to happen after #6896 is merged. I would prefer to save further refactors for TestSnapshotService until after #6896 and #7038 are merged.
Update: Problems with jsonrpc tests brought up another issue with TestSnapshotService. I'll try to resolve the issues for the RPC API, and see how much refactoring will be necessary to replace all instances of TestSnapshotService with Wrapped(Mutex<TestSnapshotService>).
| load_bundled!("ethereum/olympic") | ||
| } | ||
|
|
||
| /// Create a new spec for Operations contract |
| } | ||
|
|
||
| /// Create a new Spec with Kovan testnet using the AuthorityRound consensuse engine (not requiring work). | ||
| pub fn new_test_kovan() -> Self { |
|
|
||
| /// Convenience method to retrieve current state from a given state_db | ||
| pub fn get_in_memory_state(&self) -> Result<State<StateDB>, EvmTestError> { | ||
| { |
There was a problem hiding this comment.
Additional block unnecessary.
|
|
||
| /// Convenience method to retrieve state from a fresh state_db | ||
| pub fn get_new_state(&self) -> Result<State<StateDB>, EvmTestError> { | ||
| let (_, state_db) = get_in_memory_db(&self.spec).unwrap(); |
There was a problem hiding this comment.
why unwrap and not ? seems that the error type is the same.
| } | ||
|
|
||
| /// Convenience method to retrieve current state from a given state_db | ||
| pub fn get_in_memory_state(&self) -> Result<State<StateDB>, EvmTestError> { |
There was a problem hiding this comment.
Avoid get in function names use in_memory_state is it's a getter or new_/create_ if you are creating something.
| script: | ||
| - set RUST_BACKTRACE=1 | ||
| - echo cargo test --features json-tests -p rlp -p ethash -p ethcore -p ethcore-bigint -p parity-dapps -p parity-rpc -p ethcore-util -p ethcore-network -p ethcore-io -p ethkey -p ethstore -p ethsync -p ethcore-ipc -p ethcore-ipc-tests -p ethcore-ipc-nano -p parity-rpc-client -p parity %CARGOFLAGS% --verbose --release | ||
| - echo cargo test --features json-tests -p rlp -p ethash -p ethcore -p ethcore-bigint -p parity-dapps -p parity-rpc -p ethcore-util -p ethcore-network -p ethcore-io -p ethkey -p ethstore -p ethsync -p ethcore-ipc -p ethcore-ipc-tests -p ethcore-ipc-nano -p parity-rpc-client -p parity -p parity-updater %CARGOFLAGS% --verbose --release |
There was a problem hiding this comment.
Should go to workspace members, Why does .gitlab-ci-.yml list packages names here? CC @paritytech/ui-devs
Should only run cargo test --all
There was a problem hiding this comment.
I'll change it to cargo test --all, and revert to original if there are merge issues.
| // Write DB | ||
| { | ||
| let mut batch = kvdb::DBTransaction::new(); | ||
| state_db.journal_under(&mut batch, 0, &genesis.hash())?; |
There was a problem hiding this comment.
state_db is empty at this point, no? I don't think there is a need to write anything to the DB.
There was a problem hiding this comment.
Unsure, I took this from the existing code, and modified it to use the new state_db setup.
I don't think there is a need to write anything to the DB.
Why wouldn't we need to add the genesis hash to the DB when it is created?
|
@lght any progress on this one? |
|
Formatting changes for openethereum#6913
Formatting changes for openethereum#6913
87be7e5 to
842ef40
Compare
Part of an attempt to get updater unit tests running on automated builds for openethereum#6913.
Removed commented tests from `updater/src/updater.rs`, and will migrate them to a separate PR dedicated to unit tests for Operations.sol. Changed `test_client::get_in_memory_db` to `test_client::create_in_memory_db` to be more semantically correction, and follow better naming convention.
|
RPC tests are causing this PR's builds to fail. Changes to RPC originated from a merge with past master. Looks like the tests use a |
Part of openethereum#6913, JSON RPC tests from a merge with previous master were causing CI builds to fail.
More formatting fixes for openethereum#6913
|
please reopen if/when the pr is ready |
Updater Unit Tests
The main point of this PR is to provide basic unit tests, covering all members of the
Updater.Through the process of writing tests,
TestBlockChainClientis also undergoing some pretty heavy refactoring. The test client will now use an in-memory blockchain instead of the current HashMap.The
Operationscontract is the central feature ofUpdater. Contracts are executed locally using Parity's EVM interpreter. I still need to write unit tests exercising the smart contract functionality.Integration tests will target the Kovan test network. One cool possibility would be to make the tests generic across all available testnets. Pluggable consensus and spec configuration should make this pretty straightforward. Integration tests will likely go in their own PR.
Victories
All tests pass!
Shortcomings
Current tests are stupid simple, and test the setup of
Updatermore than anything elseComplex tests for the
Operationscontract are neededTODO
Unit tests are still needed for:
Operationscontract to in-memory blockchainOperationscontractTestBlockChainClientneeds to be refactored to use its in-memory blockchain for all block operations, instead of relying on the current HashMap-based mock blockchain.There are a couple other things I want to do, but fall outside the scope of this pull request.
Write integration tests targeting Kovan (eventually all testnets)
Create a standalone test crate:
testsmoduledevtoolsstarted (in-part?) to address this issueA hybrid of the current approach and a standalone crate may be possible. I'm thinking this might look like each Parity crate having its own publicly accessible test helper crate. To save on compilation overhead, the crates could be hidden behind feature flags. Then a separate, root-level crate (
devtools?) could import all the public test crates from each Parity component.Not sure if this hybrid approach would actually work, or is a total pipedream. Thoughts?
This change is