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:
Kian Paimani
2019-07-29 14:43:53 +02:00
committed by Bastian Köcher
parent cf80af9255
commit 79feb23a22
259 changed files with 667 additions and 665 deletions
+8 -8
View File
@@ -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());