Set ssz_derive to import from ssz::

Previously it was expecting `Encodable`, `Decodable`, etc to be in
scope, now it uses `ssz::Encodable`.
This commit is contained in:
Paul Hauner 2019-02-20 11:06:03 +13:00
parent abef6698b1
commit 586bb09e02
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
25 changed files with 51 additions and 51 deletions

View File

@ -2,7 +2,7 @@ use super::{AggregatePublicKey, AggregateSignature, AttestationData, Bitfield, H
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode)]
@ -60,7 +60,7 @@ impl<T: RngCore> TestRandom<T> for Attestation {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use crate::test_utils::TestRandom;
use crate::{AttestationDataAndCustodyBit, Crosslink, Epoch, Hash256, Slot};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
pub const SSZ_ATTESTION_DATA_LENGTH: usize = {
@ -78,7 +78,7 @@ impl<T: RngCore> TestRandom<T> for AttestationData {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::AttestationData;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::TreeHash;
use ssz_derive::{Decode, Encode};
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode)]
@ -35,7 +35,7 @@ impl<T: RngCore> TestRandom<T> for AttestationDataAndCustodyBit {
mod test {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -1,7 +1,7 @@
use crate::{test_utils::TestRandom, SlashableAttestation};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -32,7 +32,7 @@ impl<T: RngCore> TestRandom<T> for AttesterSlashing {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -3,7 +3,7 @@ use crate::{BeaconBlockBody, ChainSpec, Eth1Data, Hash256, ProposalSignedData, S
use bls::Signature;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -92,7 +92,7 @@ impl<T: RngCore> TestRandom<T> for BeaconBlock {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::{Attestation, AttesterSlashing, Deposit, Exit, ProposerSlashing};
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
@ -42,7 +42,7 @@ impl<T: RngCore> TestRandom<T> for BeaconBlockBody {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -9,7 +9,7 @@ use honey_badger_split::SplitExt;
use log::trace;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
use swap_or_not_shuffle::get_permutated_index;

View File

@ -7,7 +7,7 @@ use crate::{
Eth1Data, Hash256, Keypair,
};
use bls::create_proof_of_possession;
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
struct BeaconStateTestBuilder {
pub genesis_time: u64,

View File

@ -2,7 +2,7 @@ use super::SlashableVoteData;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -33,7 +33,7 @@ impl<T: RngCore> TestRandom<T> for CasperSlashing {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use crate::test_utils::TestRandom;
use crate::{Epoch, Hash256};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode)]
@ -43,7 +43,7 @@ impl<T: RngCore> TestRandom<T> for Crosslink {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::{DepositData, Hash256};
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -36,7 +36,7 @@ impl<T: RngCore> TestRandom<T> for Deposit {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::DepositInput;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -36,7 +36,7 @@ impl<T: RngCore> TestRandom<T> for DepositData {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -3,7 +3,7 @@ use crate::test_utils::TestRandom;
use bls::{PublicKey, Signature};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -37,7 +37,7 @@ impl<T: RngCore> TestRandom<T> for DepositInput {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::Hash256;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
// Note: this is refer to as DepositRootVote in specs
@ -34,7 +34,7 @@ impl<T: RngCore> TestRandom<T> for Eth1Data {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use super::Eth1Data;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
// Note: this is refer to as DepositRootVote in specs
@ -34,7 +34,7 @@ impl<T: RngCore> TestRandom<T> for Eth1DataVote {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use crate::{test_utils::TestRandom, Epoch};
use bls::Signature;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -36,7 +36,7 @@ impl<T: RngCore> TestRandom<T> for Exit {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -1,7 +1,7 @@
use crate::{test_utils::TestRandom, Epoch};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode)]
@ -35,7 +35,7 @@ impl<T: RngCore> TestRandom<T> for Fork {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use crate::test_utils::TestRandom;
use crate::{AttestationData, Bitfield, Slot};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode)]
@ -39,7 +39,7 @@ impl<T: RngCore> TestRandom<T> for PendingAttestation {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -2,7 +2,7 @@ use crate::test_utils::TestRandom;
use crate::{Hash256, Slot};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
@ -36,7 +36,7 @@ impl<T: RngCore> TestRandom<T> for ProposalSignedData {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -3,7 +3,7 @@ use crate::test_utils::TestRandom;
use bls::Signature;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -43,7 +43,7 @@ impl<T: RngCore> TestRandom<T> for ProposerSlashing {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -1,7 +1,7 @@
use crate::{test_utils::TestRandom, Slot};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -35,7 +35,7 @@ impl<T: RngCore> TestRandom<T> for ShardReassignmentRecord {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -1,7 +1,7 @@
use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, Bitfield};
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -38,7 +38,7 @@ impl<T: RngCore> TestRandom<T> for SlashableAttestation {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -4,7 +4,7 @@ use crate::test_utils::TestRandom;
use bls::AggregateSignature;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
@ -64,7 +64,7 @@ mod tests {
use crate::chain_spec::ChainSpec;
use crate::slot_epoch::{Epoch, Slot};
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_is_double_vote_true() {

View File

@ -2,7 +2,7 @@ use crate::{test_utils::TestRandom, Hash256, Slot};
use bls::PublicKey;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
use ssz::{hash, TreeHash};
use ssz_derive::{Decode, Encode};
// The information gathered from the PoW chain validator registration function.
@ -56,7 +56,7 @@ impl<T: RngCore> TestRandom<T> for ValidatorRegistryDeltaBlock {
mod tests {
use super::*;
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::ssz_encode;
use ssz::{ssz_encode, Decodable};
#[test]
pub fn test_ssz_round_trip() {

View File

@ -11,7 +11,7 @@
//!
//! Example:
//! ```
//! use ssz::{ssz_encode, Decodable, Encodable, SszStream, DecodeError};
//! use ssz::{ssz_encode, Decodable};
//! use ssz_derive::{Encode, Decode};
//!
//! #[derive(Encode, Decode)]
@ -68,8 +68,8 @@ pub fn ssz_encode_derive(input: TokenStream) -> TokenStream {
let field_idents = get_named_field_idents(&struct_data);
let output = quote! {
impl Encodable for #name {
fn ssz_append(&self, s: &mut SszStream) {
impl ssz::Encodable for #name {
fn ssz_append(&self, s: &mut ssz::SszStream) {
#(
s.append(&self.#field_idents);
)*
@ -103,8 +103,8 @@ pub fn ssz_decode_derive(input: TokenStream) -> TokenStream {
let field_idents_b = &field_idents;
let output = quote! {
impl Decodable for #name {
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
impl ssz::Decodable for #name {
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), ssz::DecodeError> {
#(
let (#field_idents_a, i) = <_>::ssz_decode(bytes, i)?;
)*