cleanup json crate (#11027)
* [json]: cleanup write something here.... * nit: commit new/moved files * nit: remove needless features * nits * fix(grumbles): use explicit import `DifficultyTest` * fix(grumbles): remove needless type hints * fix(grumble): docs `from -> used by` Co-Authored-By: David <dvdplm@gmail.com> * fix(grumbles): use explicit `imports` * fix(grumble): merge `tx` and `tx_with_signing_info` * fix(grumbles): resolve introduced `TODO's`
This commit is contained in:
@@ -17,11 +17,12 @@
|
||||
//! Spec account deserialization.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
use spec::builtin::Builtin;
|
||||
|
||||
use crate::{bytes::Bytes, spec::builtin::Builtin, uint::Uint};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Spec account.
|
||||
#[cfg_attr(any(test, feature = "test-helpers"), derive(Clone))]
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Account {
|
||||
@@ -50,12 +51,8 @@ impl Account {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json;
|
||||
use spec::account::Account;
|
||||
use super::{Account, Bytes, BTreeMap, Uint};
|
||||
use ethereum_types::U256;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
|
||||
#[test]
|
||||
fn account_balance_missing_not_empty() {
|
||||
|
||||
@@ -39,9 +39,8 @@
|
||||
//! ```
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use hash::Address;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, hash::Address, uint::Uint};
|
||||
use serde::Deserialize;
|
||||
use super::ValidatorSet;
|
||||
|
||||
/// Authority params deserialization.
|
||||
@@ -108,12 +107,9 @@ pub struct AuthorityRound {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Address, Uint};
|
||||
use ethereum_types::{U256, H160};
|
||||
use uint::Uint;
|
||||
use serde_json;
|
||||
use hash::Address;
|
||||
use spec::validator_set::ValidatorSet;
|
||||
use spec::authority_round::AuthorityRound;
|
||||
use crate::spec::{validator_set::ValidatorSet, authority_round::AuthorityRound};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
//! Authority params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use crate::uint::Uint;
|
||||
use super::ValidatorSet;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Authority params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -40,13 +41,10 @@ pub struct BasicAuthority {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{U256, H160};
|
||||
use hash::Address;
|
||||
use spec::basic_authority::BasicAuthority;
|
||||
use spec::validator_set::ValidatorSet;
|
||||
use std::str::FromStr;
|
||||
use super::{BasicAuthority, Uint};
|
||||
use ethereum_types::{U256, H160};
|
||||
use crate::{hash::Address, spec::validator_set::ValidatorSet};
|
||||
|
||||
#[test]
|
||||
fn basic_authority_deserialization() {
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
//! Spec builtin deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use crate::uint::Uint;
|
||||
use serde::Deserialize;
|
||||
|
||||
|
||||
/// Linear pricing.
|
||||
@@ -97,9 +98,7 @@ pub struct Builtin {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::builtin::{Builtin, Pricing, Linear, Modexp};
|
||||
use uint::Uint;
|
||||
use super::{Builtin, Modexp, Linear, Pricing, Uint};
|
||||
|
||||
#[test]
|
||||
fn builtin_deserialization() {
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
//! Clique params deserialization.
|
||||
|
||||
use std::num::NonZeroU64;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Clique params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct CliqueParams {
|
||||
/// period as defined in EIP
|
||||
/// period as defined in EIP 225
|
||||
pub period: Option<u64>,
|
||||
/// epoch length as defined in EIP
|
||||
/// epoch length as defined in EIP 225
|
||||
pub epoch: Option<NonZeroU64>
|
||||
}
|
||||
|
||||
@@ -36,8 +37,7 @@ pub struct Clique {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use super::*;
|
||||
use super::{Clique, NonZeroU64};
|
||||
|
||||
#[test]
|
||||
fn clique_deserialization() {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! Engine deserialization.
|
||||
|
||||
use super::{Ethash, BasicAuthority, AuthorityRound, NullEngine, InstantSeal, Clique};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -40,8 +41,7 @@ pub enum Engine {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::Engine;
|
||||
use super::Engine;
|
||||
|
||||
#[test]
|
||||
fn engine_deserialization() {
|
||||
|
||||
@@ -17,16 +17,21 @@
|
||||
//! Ethash params deserialization.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use uint::{self, Uint};
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
uint::{self, Uint},
|
||||
hash::Address
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Deserializable doppelganger of block rewards for EthashParams
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(untagged)]
|
||||
pub enum BlockReward {
|
||||
/// Single block reward
|
||||
Single(Uint),
|
||||
/// Several block rewards
|
||||
Multi(BTreeMap<Uint, Uint>),
|
||||
}
|
||||
|
||||
@@ -110,12 +115,9 @@ pub struct Ethash {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use spec::ethash::{Ethash, EthashParams, BlockReward};
|
||||
use std::str::FromStr;
|
||||
use super::{Address, BlockReward, Ethash, EthashParams, Uint};
|
||||
use ethereum_types::{H160, U256};
|
||||
|
||||
#[test]
|
||||
fn ethash_deserialization() {
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
//! Spec genesis deserialization.
|
||||
|
||||
use uint::{Uint, self};
|
||||
use hash::{Address, H256};
|
||||
use bytes::Bytes;
|
||||
use spec::Seal;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, H256},
|
||||
spec::Seal,
|
||||
uint::{self, Uint},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Spec genesis.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -53,14 +56,13 @@ pub struct Genesis {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use bytes::Bytes;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{U256, H160, H64 as Eth64, H256 as Eth256};
|
||||
use hash::{H64, H256, Address};
|
||||
use spec::genesis::Genesis;
|
||||
use spec::{Ethereum, Seal};
|
||||
use std::str::FromStr;
|
||||
use super::{Address, Bytes, Genesis, H256, Uint};
|
||||
use crate::{
|
||||
hash::H64,
|
||||
spec::{Ethereum, Seal}
|
||||
};
|
||||
use ethereum_types::{U256, H160, H64 as Eth64, H256 as Eth256};
|
||||
|
||||
#[test]
|
||||
fn genesis_deserialization() {
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
//! Spec hardcoded synchronization deserialization for the light client.
|
||||
|
||||
use hash::H256;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, hash::H256, uint::Uint};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Spec hardcoded sync.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -36,12 +35,9 @@ pub struct HardcodedSync {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{U256, H256 as Eth256};
|
||||
use hash::H256;
|
||||
use spec::hardcoded_sync::HardcodedSync;
|
||||
use std::str::FromStr;
|
||||
use super::{H256, HardcodedSync, Uint};
|
||||
use ethereum_types::{U256, H256 as Eth256};
|
||||
|
||||
#[test]
|
||||
fn hardcoded_sync_deserialization() {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
//! Instant seal engine params deserialization.
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Instant seal engine params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
//! Null engine params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use crate::uint::Uint;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Authority params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -39,10 +40,8 @@ pub struct NullEngine {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use super::{NullEngine, Uint};
|
||||
use ethereum_types::U256;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn null_engine_deserialization() {
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
//! Spec params deserialization.
|
||||
|
||||
use uint::{self, Uint};
|
||||
use hash::{H256, Address};
|
||||
use bytes::Bytes;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{H256, Address},
|
||||
uint::{self, Uint}
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Spec params.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -140,18 +143,16 @@ pub struct Params {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use super::{Params, Uint};
|
||||
use ethereum_types::U256;
|
||||
use spec::params::Params;
|
||||
|
||||
#[test]
|
||||
fn params_deserialization() {
|
||||
let s = r#"{
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"networkID" : "0x1",
|
||||
"chainID" : "0x15",
|
||||
"subprotocolName" : "exp",
|
||||
"networkID": "0x1",
|
||||
"chainID": "0x15",
|
||||
"subprotocolName": "exp",
|
||||
"minGasLimit": "0x1388",
|
||||
"accountStartNonce": "0x01",
|
||||
"gasLimitBoundDivisor": "0x20",
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
//! Spec seal deserialization.
|
||||
|
||||
use hash::*;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, hash::{H64, H256, H520}, uint::Uint};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Ethereum seal.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -70,13 +69,9 @@ pub enum Seal {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use hash::*;
|
||||
use bytes::Bytes;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{U256, H64 as Eth64, H256 as Eth256, H520 as Eth520};
|
||||
use spec::{Ethereum, AuthorityRoundSeal, TendermintSeal, Seal};
|
||||
use std::str::FromStr;
|
||||
use super::{AuthorityRoundSeal, Bytes, Ethereum, H64, H256, H520, TendermintSeal, Seal, Uint};
|
||||
use ethereum_types::{U256, H64 as Eth64, H256 as Eth256, H520 as Eth520};
|
||||
|
||||
#[test]
|
||||
fn seal_deserialization() {
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
//! Spec deserialization.
|
||||
|
||||
use std::io::Read;
|
||||
use serde_json;
|
||||
use crate::spec::{Params, Genesis, Engine, State, HardcodedSync};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Error;
|
||||
use spec::{Params, Genesis, Engine, State, HardcodedSync};
|
||||
|
||||
/// Fork spec definition
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize)]
|
||||
@@ -70,8 +70,7 @@ impl Spec {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::spec::Spec;
|
||||
use super::Spec;
|
||||
|
||||
#[test]
|
||||
fn should_error_on_unknown_fields() {
|
||||
|
||||
@@ -14,14 +14,24 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Blockchain test state deserializer.
|
||||
//! Blockchain state deserializer.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use hash::Address;
|
||||
use bytes::Bytes;
|
||||
use spec::{Account, Builtin};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::Address,
|
||||
spec::{Account, Builtin}
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Blockchain test state deserializer.
|
||||
/// Blockchain state deserializer for tests
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct State(pub BTreeMap<Address, Account>);
|
||||
|
||||
/// Blockchain state deserializer.
|
||||
#[cfg(not(any(test, feature = "test-helpers")))]
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct State(BTreeMap<Address, Account>);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//! Validator set deserialization.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
use hash::Address;
|
||||
use crate::{hash::Address, uint::Uint};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Different ways of specifying validators.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -37,12 +37,9 @@ pub enum ValidatorSet {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use spec::validator_set::ValidatorSet;
|
||||
use std::str::FromStr;
|
||||
use super::{Address, Uint, ValidatorSet};
|
||||
use ethereum_types::{H160, U256};
|
||||
|
||||
#[test]
|
||||
fn validator_set_deserialization() {
|
||||
|
||||
Reference in New Issue
Block a user