This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move snapshot related traits to their proper place (#11012)
* Move snapshot to own crate Sort out imports * WIP cargo toml * Make snapshotting generic over the client Sort out tests * Sort out types from blockchain and client * Sort out sync * Sort out imports and generics * Sort out main binary * Fix sync test-helpers * Sort out import for secret-store * Sort out more imports * Fix easy todos * cleanup * Move SnapshotClient and SnapshotWriter to their proper places Sort out the circular dependency between snapshot and ethcore by moving all snapshot tests to own crate, snapshot-tests * cleanup * Cleanup * fix merge issues * Update ethcore/snapshot/snapshot-tests/Cargo.toml Co-Authored-By: Andronik Ordian <write@reusable.software> * Sort out botched merge * Ensure snapshot-tests run * Docs * Fix grumbles
- Loading branch information
Showing
25 changed files
with
860 additions
and
676 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,44 @@ | ||
[package] | ||
name = "snapshot-tests" | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <admin@parity.io>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
accounts = { package = "ethcore-accounts", path = "../../../accounts" } | ||
account-db = { path = "../../account-db" } | ||
account-state = { path = "../../account-state" } | ||
blockchain = { package = "ethcore-blockchain", path = "../../blockchain" } | ||
bytes = { package = "parity-bytes", version = "0.1.0" } | ||
client-traits = { path = "../../client-traits" } | ||
common-types = { path = "../../types" } | ||
engine = { path = "../../engine", features = ["test-helpers"] } | ||
env_logger = "0.5" | ||
ethcore = { path = "../..", features = ["test-helpers"] } | ||
ethcore-db = { path = "../../db" } | ||
ethcore-io = { path = "../../../util/io" } | ||
ethereum-types = "0.6.0" | ||
ethkey = { path = "../../../accounts/ethkey" } | ||
ethtrie = { package = "patricia-trie-ethereum", path = "../../../util/patricia-trie-ethereum" } | ||
hash-db = "0.15.0" | ||
journaldb = { path = "../../../util/journaldb" } | ||
keccak-hash = "0.2.0" | ||
keccak-hasher = { path = "../../../util/keccak-hasher" } | ||
kvdb = "0.1.0" | ||
kvdb-rocksdb = { version = "0.1.3" } | ||
log = "0.4.8" | ||
parking_lot = "0.8.0" | ||
rand = "0.6" | ||
rand_xorshift = "0.1.1" | ||
rlp = "0.4.2" | ||
snappy = { package = "parity-snappy", version ="0.1.0" } | ||
snapshot = { path = "../../snapshot", features = ["test-helpers"] } | ||
spec = { path = "../../spec" } | ||
tempdir = "0.3" | ||
trie-db = "0.15.0" | ||
trie-standardmap = "0.15.0" | ||
ethabi = "8.0" | ||
ethabi-contract = "8.0" | ||
ethabi-derive = "8.0" | ||
lazy_static = { version = "1.3" } | ||
triehash = { package = "triehash-ethereum", version = "0.2", path = "../../../util/triehash-ethereum" } |
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,89 @@ | ||
// Copyright 2015-2019 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Ethereum. | ||
|
||
// Parity Ethereum is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity Ethereum is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Tests for block RLP encoding | ||
|
||
use snapshot::test_helpers::AbridgedBlock; | ||
|
||
use bytes::Bytes; | ||
use ethereum_types::{H256, U256, Address}; | ||
use common_types::{ | ||
transaction::{Action, Transaction}, | ||
block::Block, | ||
view, | ||
views::BlockView, | ||
}; | ||
|
||
fn encode_block(b: &Block) -> Bytes { | ||
b.rlp_bytes() | ||
} | ||
|
||
#[test] | ||
fn empty_block_abridging() { | ||
let b = Block::default(); | ||
let receipts_root = b.header.receipts_root().clone(); | ||
let encoded = encode_block(&b); | ||
|
||
let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded)); | ||
assert_eq!(abridged.to_block(H256::zero(), 0, receipts_root).unwrap(), b); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn wrong_number() { | ||
let b = Block::default(); | ||
let receipts_root = b.header.receipts_root().clone(); | ||
let encoded = encode_block(&b); | ||
|
||
let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded)); | ||
assert_eq!(abridged.to_block(H256::zero(), 2, receipts_root).unwrap(), b); | ||
} | ||
|
||
#[test] | ||
fn with_transactions() { | ||
let mut b = Block::default(); | ||
|
||
let t1 = Transaction { | ||
action: Action::Create, | ||
nonce: U256::from(42), | ||
gas_price: U256::from(3000), | ||
gas: U256::from(50_000), | ||
value: U256::from(1), | ||
data: b"Hello!".to_vec() | ||
}.fake_sign(Address::from_low_u64_be(0x69)); | ||
|
||
let t2 = Transaction { | ||
action: Action::Create, | ||
nonce: U256::from(88), | ||
gas_price: U256::from(12345), | ||
gas: U256::from(300000), | ||
value: U256::from(1000000000), | ||
data: "Eep!".into(), | ||
}.fake_sign(Address::from_low_u64_be(0x55)); | ||
|
||
b.transactions.push(t1.into()); | ||
b.transactions.push(t2.into()); | ||
|
||
let receipts_root = b.header.receipts_root().clone(); | ||
b.header.set_transactions_root(triehash::ordered_trie_root( | ||
b.transactions.iter().map(::rlp::encode) | ||
)); | ||
|
||
let encoded = encode_block(&b); | ||
|
||
let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded[..])); | ||
assert_eq!(abridged.to_block(H256::zero(), 0, receipts_root).unwrap(), b); | ||
} |
Oops, something went wrong.