mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Refactor sr_primitives. (#3214)
* refactor sr_primitives. * Fix try build error. * Line-width * Ui test. * Final fixes. * Fix build again. * bring back ui test. * Fix unsigned import. * Another ui fix. * Also refactor substrate-primitives * Fix benchmarks. * Fix doc test. * fix doc tests
This commit is contained in:
committed by
Bastian Köcher
parent
cf80af9255
commit
79feb23a22
@@ -14,7 +14,7 @@ offchain-primitives = { package = "substrate-offchain-primitives", path = "./pri
|
||||
parity-codec = { version = "4.1.1", features = ["derive"] }
|
||||
parking_lot = "0.8.0"
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" }
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
|
||||
network = { package = "substrate-network", path = "../../core/network" }
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
client = { package = "substrate-client", path = "../../client", default-features = false }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives", default-features = false }
|
||||
sr-primitives = { path = "../../sr-primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"client/std",
|
||||
"runtime_primitives/std"
|
||||
"sr-primitives/std"
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use client::decl_runtime_apis;
|
||||
use runtime_primitives::traits::NumberFor;
|
||||
use sr_primitives::traits::NumberFor;
|
||||
|
||||
decl_runtime_apis! {
|
||||
/// The offchain worker api.
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
convert::{TryFrom, TryInto},
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
convert::{TryFrom, TryInto},
|
||||
time::{SystemTime, Duration},
|
||||
thread::sleep,
|
||||
};
|
||||
@@ -36,7 +36,7 @@ use primitives::offchain::{
|
||||
};
|
||||
use primitives::crypto::{Pair, Public, Protected};
|
||||
use primitives::{ed25519, sr25519};
|
||||
use runtime_primitives::{
|
||||
use sr_primitives::{
|
||||
generic::BlockId,
|
||||
traits::{self, Extrinsic},
|
||||
};
|
||||
@@ -569,7 +569,7 @@ impl<A: ChainApi> AsyncApi<A> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::convert::TryFrom;
|
||||
use runtime_primitives::traits::Zero;
|
||||
use sr_primitives::traits::Zero;
|
||||
use client_db::offchain::LocalStorage;
|
||||
use crate::tests::TestProvider;
|
||||
use network::PeerId;
|
||||
@@ -602,14 +602,14 @@ mod tests {
|
||||
#[test]
|
||||
fn should_get_timestamp() {
|
||||
let mut api = offchain_api().0;
|
||||
|
||||
|
||||
// Get timestamp from std.
|
||||
let now = SystemTime::now();
|
||||
let d: u64 = now.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis().try_into().unwrap();
|
||||
|
||||
// Get timestamp from offchain api.
|
||||
let timestamp = api.timestamp();
|
||||
|
||||
|
||||
// Compare.
|
||||
assert!(timestamp.unix_millis() > 0);
|
||||
assert_eq!(timestamp.unix_millis(), d);
|
||||
@@ -627,7 +627,7 @@ mod tests {
|
||||
// Act.
|
||||
api.sleep_until(deadline);
|
||||
let new_now = api.timestamp();
|
||||
|
||||
|
||||
// Assert.
|
||||
// The diff could be more than the sleep duration.
|
||||
assert!(new_now.unix_millis() - 100 >= now.unix_millis());
|
||||
|
||||
@@ -45,7 +45,7 @@ use primitives::{
|
||||
ExecutionContext,
|
||||
crypto,
|
||||
};
|
||||
use runtime_primitives::{
|
||||
use sr_primitives::{
|
||||
generic::BlockId,
|
||||
traits::{self, ProvideRuntimeApi},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user