mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
sp-npos-elections should not depend on itself (#6444)
This removes the `dev-dependency` onto `sp-npos-elections` from itself. A crate should not depend on itself directly, especially not to make any macros work.
This commit is contained in:
Generated
-1
@@ -7634,7 +7634,6 @@ dependencies = [
|
|||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"serde",
|
"serde",
|
||||||
"sp-arithmetic",
|
"sp-arithmetic",
|
||||||
"sp-npos-elections",
|
|
||||||
"sp-npos-elections-compact",
|
"sp-npos-elections-compact",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"sp-std",
|
"sp-std",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ sp-arithmetic = { version = "2.0.0-rc3", default-features = false, path = "../ar
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
substrate-test-utils = { version = "2.0.0-rc3", path = "../../test-utils" }
|
substrate-test-utils = { version = "2.0.0-rc3", path = "../../test-utils" }
|
||||||
rand = "0.7.3"
|
rand = "0.7.3"
|
||||||
sp-npos-elections = { version = "2.0.0-rc3", path = "." }
|
|
||||||
sp-runtime = { version = "2.0.0-rc3", path = "../../primitives/runtime" }
|
sp-runtime = { version = "2.0.0-rc3", path = "../../primitives/runtime" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
//! Code generation for the ratio assignment type.
|
//! Code generation for the ratio assignment type.
|
||||||
|
|
||||||
use crate::field_name_for;
|
use crate::field_name_for;
|
||||||
use proc_macro2::{TokenStream as TokenStream2};
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use syn::{GenericArgument};
|
use syn::GenericArgument;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
fn from_impl(count: usize) -> TokenStream2 {
|
fn from_impl(count: usize) -> TokenStream2 {
|
||||||
|
|||||||
@@ -224,17 +224,19 @@ fn struct_def(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn imports() -> Result<TokenStream2> {
|
fn imports() -> Result<TokenStream2> {
|
||||||
let sp_phragmen_imports = match crate_name("sp-npos-elections") {
|
if std::env::var("CARGO_PKG_NAME").unwrap() == "sp-npos-elections" {
|
||||||
Ok(sp_npos_elections) => {
|
Ok(quote! {
|
||||||
let ident = syn::Ident::new(&sp_npos_elections, Span::call_site());
|
use crate as _phragmen;
|
||||||
quote!( extern crate #ident as _phragmen; )
|
})
|
||||||
|
} else {
|
||||||
|
match crate_name("sp-npos-elections") {
|
||||||
|
Ok(sp_npos_elections) => {
|
||||||
|
let ident = syn::Ident::new(&sp_npos_elections, Span::call_site());
|
||||||
|
Ok(quote!( extern crate #ident as _phragmen; ))
|
||||||
|
},
|
||||||
|
Err(e) => Err(syn::Error::new(Span::call_site(), &e)),
|
||||||
}
|
}
|
||||||
Err(e) => return Err(syn::Error::new(Span::call_site(), &e)),
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Ok(quote!(
|
|
||||||
#sp_phragmen_imports
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CompactSolutionDef {
|
struct CompactSolutionDef {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
//! Tests for npos-elections.
|
//! Tests for npos-elections.
|
||||||
|
|
||||||
#![cfg(test)]
|
|
||||||
|
|
||||||
use crate::mock::*;
|
use crate::mock::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
seq_phragmen, balance_solution, build_support_map, is_score_better, helpers::*,
|
seq_phragmen, balance_solution, build_support_map, is_score_better, helpers::*,
|
||||||
@@ -772,10 +770,12 @@ fn score_comparison_large_value() {
|
|||||||
|
|
||||||
mod compact {
|
mod compact {
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use crate::{generate_compact_solution_type, VoteWeight};
|
use super::AccountId;
|
||||||
use super::{AccountId};
|
|
||||||
// these need to come from the same dev-dependency `sp-npos-elections`, not from the crate.
|
// these need to come from the same dev-dependency `sp-npos-elections`, not from the crate.
|
||||||
use sp_npos_elections::{Assignment, StakedAssignment, Error as PhragmenError, ExtendedBalance};
|
use crate::{
|
||||||
|
generate_compact_solution_type, VoteWeight, Assignment, StakedAssignment,
|
||||||
|
Error as PhragmenError, ExtendedBalance,
|
||||||
|
};
|
||||||
use sp_std::{convert::{TryInto, TryFrom}, fmt::Debug};
|
use sp_std::{convert::{TryInto, TryFrom}, fmt::Debug};
|
||||||
use sp_arithmetic::Percent;
|
use sp_arithmetic::Percent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user