diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 6dc6440056..99ebbf44cc 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -2341,14 +2341,13 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3864,7 +3863,7 @@ dependencies = [ "parity-codec 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4578,7 +4577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5137,7 +5136,7 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "28ea5118e2f41bfbc974b28d88c07621befd1fa5d6ec23549be96302a1a59dd2" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" -"checksum primitive-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f47c18b4601125931d69fcf7b000c2c16a304e4f84d58218d6470b4502e00b58" +"checksum primitive-types 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f98b65b49b3979da4f94651c07a60a7879374d7d49de0036ecd116ee25c975b5" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" "checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4" @@ -5267,7 +5266,7 @@ dependencies = [ "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "082df6964410f6aa929a61ddfafc997e4f32c62c22490e439ac351cec827f436" +"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3218ea14b4edcaccfa0df0a64a3792a2c32cc706f1b336e48867f9d3147f90" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/substrate/core/client/db/src/cache/list_cache.rs b/substrate/core/client/db/src/cache/list_cache.rs index e40dcda313..f8e52e14c6 100644 --- a/substrate/core/client/db/src/cache/list_cache.rs +++ b/substrate/core/client/db/src/cache/list_cache.rs @@ -585,6 +585,7 @@ fn read_forks>( #[cfg(test)] pub mod tests { + use test_client::runtime::H256; use runtime_primitives::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; use runtime_primitives::traits::Header as HeaderT; use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction}; @@ -593,7 +594,7 @@ pub mod tests { type Block = RawBlock>; pub fn test_id(number: u64) -> ComplexBlockId { - ComplexBlockId::new(From::from(number), number) + ComplexBlockId::new(H256::from_low_u64_be(number), number) } fn correct_id(number: u64) -> ComplexBlockId { @@ -621,7 +622,7 @@ pub mod tests { Header { parent_hash: fork_header(fork_nonce, fork_from, number - 1).hash(), number, - state_root: (1 + fork_nonce).into(), + state_root: H256::from_low_u64_be(1 + fork_nonce), extrinsics_root: Default::default(), digest: Default::default(), } @@ -640,7 +641,7 @@ pub mod tests { assert_eq!(ListCache::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(50, 50.into()) + .with_id(50, H256::from_low_u64_be(50)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: Some(100) }) .with_entry(test_id(30), StorageEntry { prev_valid_from: None, value: None }), 1024, test_id(100) @@ -650,7 +651,7 @@ pub mod tests { assert_eq!(ListCache::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(50, 50.into()) + .with_id(50, H256::from_low_u64_be(50)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: Some(100) }) .with_entry(test_id(30), StorageEntry { prev_valid_from: None, value: Some(30) }), 1024, test_id(100) @@ -660,7 +661,7 @@ pub mod tests { assert_eq!(ListCache::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(100, 100.into()) + .with_id(100, H256::from_low_u64_be(100)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: Some(100) }) .with_entry(test_id(30), StorageEntry { prev_valid_from: None, value: Some(30) }), 1024, test_id(100) @@ -671,18 +672,18 @@ pub mod tests { assert_eq!(ListCache::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(50, 50.into()) + .with_id(50, H256::from_low_u64_be(50)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: Some(100) }) .with_entry(test_id(30), StorageEntry { prev_valid_from: None, value: Some(30) }), 1024, test_id(100) - ).value_at_block(&ComplexBlockId::new(2.into(), 100)).unwrap(), None); + ).value_at_block(&ComplexBlockId::new(H256::from_low_u64_be(2), 100)).unwrap(), None); // when block is later than last finalized block AND there are no forks AND finalized value is None // ---> [100] --- 200 assert_eq!(ListCache::<_, u64, _>::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(50, 50.into()) + .with_id(50, H256::from_low_u64_be(50)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: None }), 1024, test_id(100) ).value_at_block(&test_id(200)).unwrap(), None); @@ -691,7 +692,7 @@ pub mod tests { assert_eq!(ListCache::new( DummyStorage::new() .with_meta(Some(test_id(100)), Vec::new()) - .with_id(50, 50.into()) + .with_id(50, H256::from_low_u64_be(50)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(30)), value: Some(100) }), 1024, test_id(100) ).value_at_block(&test_id(200)).unwrap(), Some(100)); @@ -1213,14 +1214,14 @@ pub mod tests { #[test] fn fork_destroy_works() { // when we reached finalized entry without iterations - let storage = DummyStorage::new().with_id(100, 100.into()); + let storage = DummyStorage::new().with_id(100, H256::from_low_u64_be(100)); let mut tx = DummyTransaction::new(); Fork::<_, u64> { best_block: None, head: Entry { valid_from: test_id(100), value: None } } .destroy(&storage, &mut tx, Some(200)).unwrap(); assert!(tx.removed_entries().is_empty()); // when we reach finalized entry with iterations let storage = DummyStorage::new() - .with_id(10, 10.into()) + .with_id(10, H256::from_low_u64_be(10)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(50)), value: Some(100) }) .with_entry(test_id(50), StorageEntry { prev_valid_from: Some(test_id(20)), value: Some(50) }) .with_entry(test_id(20), StorageEntry { prev_valid_from: Some(test_id(10)), value: Some(20) }) @@ -1234,7 +1235,7 @@ pub mod tests { vec![test_id(100).hash, test_id(50).hash, test_id(20).hash].into_iter().collect()); // when we reach beginning of fork before finalized block let storage = DummyStorage::new() - .with_id(10, 10.into()) + .with_id(10, H256::from_low_u64_be(10)) .with_entry(test_id(100), StorageEntry { prev_valid_from: Some(test_id(50)), value: Some(100) }) .with_entry(test_id(50), StorageEntry { prev_valid_from: None, value: Some(50) }); let mut tx = DummyTransaction::new(); @@ -1303,10 +1304,10 @@ pub mod tests { assert_eq!(chain::is_finalized_block::<_, u64, _>(&DummyStorage::new(), &test_id(1), 100).unwrap(), false); // when there's different hash for this block number in the database assert_eq!(chain::is_finalized_block::<_, u64, _>(&DummyStorage::new() - .with_id(1, From::from(2)), &test_id(1), 100).unwrap(), false); + .with_id(1, H256::from_low_u64_be(2)), &test_id(1), 100).unwrap(), false); // when there's the same hash for this block number in the database assert_eq!(chain::is_finalized_block::<_, u64, _>(&DummyStorage::new() - .with_id(1, From::from(1)), &test_id(1), 100).unwrap(), true); + .with_id(1, H256::from_low_u64_be(1)), &test_id(1), 100).unwrap(), true); } #[test] @@ -1356,9 +1357,9 @@ pub mod tests { #[test] fn ancient_entries_are_pruned() { let cache = ListCache::new(DummyStorage::new() - .with_id(10, 10.into()) - .with_id(20, 20.into()) - .with_id(30, 30.into()) + .with_id(10, H256::from_low_u64_be(10)) + .with_id(20, H256::from_low_u64_be(20)) + .with_id(30, H256::from_low_u64_be(30)) .with_entry(test_id(10), StorageEntry { prev_valid_from: None, value: Some(10) }) .with_entry(test_id(20), StorageEntry { prev_valid_from: Some(test_id(10)), value: Some(20) }) .with_entry(test_id(30), StorageEntry { prev_valid_from: Some(test_id(20)), value: Some(30) }), diff --git a/substrate/core/client/db/src/light.rs b/substrate/core/client/db/src/light.rs index 3e197e5ae7..13765bfe5d 100644 --- a/substrate/core/client/db/src/light.rs +++ b/substrate/core/client/db/src/light.rs @@ -554,7 +554,7 @@ pub(crate) mod tests { #[test] fn does_not_return_unknown_header() { let db = LightStorage::::new_test(); - assert!(db.header(BlockId::Hash(1.into())).unwrap().is_none()); + assert!(db.header(BlockId::Hash(Hash::from_low_u64_be(1))).unwrap().is_none()); assert!(db.header(BlockId::Number(0)).unwrap().is_none()); } @@ -579,7 +579,7 @@ pub(crate) mod tests { let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); assert_eq!(db.status(BlockId::Hash(genesis_hash)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Number(0)).unwrap(), BlockStatus::InChain); - assert_eq!(db.status(BlockId::Hash(1.into())).unwrap(), BlockStatus::Unknown); + assert_eq!(db.status(BlockId::Hash(Hash::from_low_u64_be(1))).unwrap(), BlockStatus::Unknown); assert_eq!(db.status(BlockId::Number(1)).unwrap(), BlockStatus::Unknown); } diff --git a/substrate/core/client/src/cht.rs b/substrate/core/client/src/cht.rs index 5797f3e279..59377b5325 100644 --- a/substrate/core/client/src/cht.rs +++ b/substrate/core/client/src/cht.rs @@ -339,20 +339,20 @@ mod tests { #[test] fn build_pairs_fails_when_no_enough_blocks() { assert!(build_pairs::(SIZE, 0, - ::std::iter::repeat_with(|| Ok(Some(1.into()))).take(SIZE as usize / 2)).is_err()); + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize / 2)).is_err()); } #[test] fn build_pairs_fails_when_missing_block() { - assert!(build_pairs::(SIZE, 0, ::std::iter::repeat_with(|| Ok(Some(1.into()))).take(SIZE as usize / 2) + assert!(build_pairs::(SIZE, 0, ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize / 2) .chain(::std::iter::once(Ok(None))) - .chain(::std::iter::repeat_with(|| Ok(Some(2.into()))).take(SIZE as usize / 2 - 1))).is_err()); + .chain(::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(2)))).take(SIZE as usize / 2 - 1))).is_err()); } #[test] fn compute_root_works() { assert!(compute_root::(SIZE, 42, - ::std::iter::repeat_with(|| Ok(Some(1.into()))).take(SIZE as usize)).is_ok()); + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_ok()); } #[test] @@ -360,14 +360,14 @@ mod tests { fn build_proof_panics_when_querying_wrong_block() { assert!(build_proof::( SIZE, 0, vec![(SIZE * 1000) as u64], - ::std::iter::repeat_with(|| Ok(Some(1.into()))).take(SIZE as usize)).is_err()); + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_err()); } #[test] fn build_proof_works() { assert!(build_proof::( SIZE, 0, vec![(SIZE / 2) as u64], - ::std::iter::repeat_with(|| Ok(Some(1.into()))).take(SIZE as usize)).is_ok()); + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_ok()); } #[test] diff --git a/substrate/core/client/src/notifications.rs b/substrate/core/client/src/notifications.rs index 1856932ca9..dae0ad2599 100644 --- a/substrate/core/client/src/notifications.rs +++ b/substrate/core/client/src/notifications.rs @@ -213,10 +213,10 @@ mod tests { (vec![2], Some(vec![3])), (vec![3], None), ]; - notifications.trigger(&1.into(), changeset.into_iter()); + notifications.trigger(&Hash::from_low_u64_be(1), changeset.into_iter()); // then - assert_eq!(recv.next().unwrap(), Ok((1.into(), vec![ + assert_eq!(recv.next().unwrap(), Ok((Hash::from_low_u64_be(1), vec![ (StorageKey(vec![2]), Some(StorageData(vec![3]))), (StorageKey(vec![3]), None), ].into()))); @@ -234,13 +234,13 @@ mod tests { (vec![2], Some(vec![3])), (vec![1], None), ]; - notifications.trigger(&1.into(), changeset.into_iter()); + notifications.trigger(&Hash::from_low_u64_be(1), changeset.into_iter()); // then - assert_eq!(recv1.next().unwrap(), Ok((1.into(), vec![ + assert_eq!(recv1.next().unwrap(), Ok((Hash::from_low_u64_be(1), vec![ (StorageKey(vec![1]), None), ].into()))); - assert_eq!(recv2.next().unwrap(), Ok((1.into(), vec![ + assert_eq!(recv2.next().unwrap(), Ok((Hash::from_low_u64_be(1), vec![ (StorageKey(vec![2]), Some(StorageData(vec![3]))), ].into()))); } @@ -262,7 +262,7 @@ mod tests { (vec![2], Some(vec![3])), (vec![1], None), ]; - notifications.trigger(&1.into(), changeset.into_iter()); + notifications.trigger(&Hash::from_low_u64_be(1), changeset.into_iter()); // then assert_eq!(notifications.listeners.len(), 0); @@ -278,7 +278,7 @@ mod tests { // when let changeset = vec![]; - notifications.trigger(&1.into(), changeset.into_iter()); + notifications.trigger(&Hash::from_low_u64_be(1), changeset.into_iter()); recv }; diff --git a/substrate/core/finality-grandpa/src/finality_proof.rs b/substrate/core/finality-grandpa/src/finality_proof.rs index c927aa68a0..ddf656c79f 100644 --- a/substrate/core/finality-grandpa/src/finality_proof.rs +++ b/substrate/core/finality-grandpa/src/finality_proof.rs @@ -269,11 +269,11 @@ mod tests { 0 => Default::default(), _ => header(number - 1).hash(), }; - Header::new(number, 0.into(), 0.into(), parent_hash, Default::default()) + Header::new(number, H256::from_low_u64_be(0), H256::from_low_u64_be(0), parent_hash, Default::default()) } fn side_header(number: u64) -> Header { - Header::new(number, 0.into(), 1.into(), header(number - 1).hash(), Default::default()) + Header::new(number, H256::from_low_u64_be(0), H256::from_low_u64_be(1), header(number - 1).hash(), Default::default()) } fn test_blockchain() -> InMemoryBlockchain { @@ -304,7 +304,7 @@ mod tests { blockchain.insert(header(5).hash(), header(5), Some(vec![5]), None, NewBlockState::Final).unwrap(); // when asking for finality of side-block 42, None is returned - let proof_of_side_4_fails = prove_finality(&blockchain, |_, _, _| Ok(vec![vec![42]]), 42.into()).is_err(); + let proof_of_side_4_fails = prove_finality(&blockchain, |_, _, _| Ok(vec![vec![42]]), H256::from_low_u64_be(42)).is_err(); assert_eq!(proof_of_side_4_fails, true); } @@ -314,7 +314,7 @@ mod tests { blockchain.insert(header(4).hash(), header(4), None, None, NewBlockState::Final).unwrap(); // when asking for finality of block 4, search for justification failing - let proof_of_4_fails = prove_finality(&blockchain, |_, _, _| Ok(vec![vec![42]]), 42.into()).is_err(); + let proof_of_4_fails = prove_finality(&blockchain, |_, _, _| Ok(vec![vec![42]]), H256::from_low_u64_be(42)).is_err(); assert_eq!(proof_of_4_fails, true); } diff --git a/substrate/core/finality-grandpa/src/tests.rs b/substrate/core/finality-grandpa/src/tests.rs index 96059eb46b..d025796f08 100644 --- a/substrate/core/finality-grandpa/src/tests.rs +++ b/substrate/core/finality-grandpa/src/tests.rs @@ -667,18 +667,18 @@ fn consensus_changes_works() { let mut changes = ConsensusChanges::::empty(); // pending changes are not finalized - changes.note_change((10, 1.into())); - assert_eq!(changes.finalize((5, 5.into()), |_| Ok(None)).unwrap(), (false, false)); + changes.note_change((10, H256::from_low_u64_be(1))); + assert_eq!(changes.finalize((5, H256::from_low_u64_be(5)), |_| Ok(None)).unwrap(), (false, false)); // no change is selected from competing pending changes - changes.note_change((1, 1.into())); - changes.note_change((1, 101.into())); - assert_eq!(changes.finalize((10, 10.into()), |_| Ok(Some(1001.into()))).unwrap(), (true, false)); + changes.note_change((1, H256::from_low_u64_be(1))); + changes.note_change((1, H256::from_low_u64_be(101))); + assert_eq!(changes.finalize((10, H256::from_low_u64_be(10)), |_| Ok(Some(H256::from_low_u64_be(1001)))).unwrap(), (true, false)); // change is selected from competing pending changes - changes.note_change((1, 1.into())); - changes.note_change((1, 101.into())); - assert_eq!(changes.finalize((10, 10.into()), |_| Ok(Some(1.into()))).unwrap(), (true, true)); + changes.note_change((1, H256::from_low_u64_be(1))); + changes.note_change((1, H256::from_low_u64_be(101))); + assert_eq!(changes.finalize((10, H256::from_low_u64_be(10)), |_| Ok(Some(H256::from_low_u64_be(1)))).unwrap(), (true, true)); } #[test] diff --git a/substrate/core/primitives/src/hash.rs b/substrate/core/primitives/src/hash.rs index 98a906861f..e4ebbe4b1e 100644 --- a/substrate/core/primitives/src/hash.rs +++ b/substrate/core/primitives/src/hash.rs @@ -37,12 +37,12 @@ mod tests { fn test_h160() { let tests = vec![ (Default::default(), "0x0000000000000000000000000000000000000000"), - (H160::from(2), "0x0000000000000000000000000000000000000002"), - (H160::from(15), "0x000000000000000000000000000000000000000f"), - (H160::from(16), "0x0000000000000000000000000000000000000010"), - (H160::from(1_000), "0x00000000000000000000000000000000000003e8"), - (H160::from(100_000), "0x00000000000000000000000000000000000186a0"), - (H160::from(u64::max_value()), "0x000000000000000000000000ffffffffffffffff"), + (H160::from_low_u64_be(2), "0x0000000000000000000000000000000000000002"), + (H160::from_low_u64_be(15), "0x000000000000000000000000000000000000000f"), + (H160::from_low_u64_be(16), "0x0000000000000000000000000000000000000010"), + (H160::from_low_u64_be(1_000), "0x00000000000000000000000000000000000003e8"), + (H160::from_low_u64_be(100_000), "0x00000000000000000000000000000000000186a0"), + (H160::from_low_u64_be(u64::max_value()), "0x000000000000000000000000ffffffffffffffff"), ]; for (number, expected) in tests { @@ -55,12 +55,12 @@ mod tests { fn test_h256() { let tests = vec![ (Default::default(), "0x0000000000000000000000000000000000000000000000000000000000000000"), - (H256::from(2), "0x0000000000000000000000000000000000000000000000000000000000000002"), - (H256::from(15), "0x000000000000000000000000000000000000000000000000000000000000000f"), - (H256::from(16), "0x0000000000000000000000000000000000000000000000000000000000000010"), - (H256::from(1_000), "0x00000000000000000000000000000000000000000000000000000000000003e8"), - (H256::from(100_000), "0x00000000000000000000000000000000000000000000000000000000000186a0"), - (H256::from(u64::max_value()), "0x000000000000000000000000000000000000000000000000ffffffffffffffff"), + (H256::from_low_u64_be(2), "0x0000000000000000000000000000000000000000000000000000000000000002"), + (H256::from_low_u64_be(15), "0x000000000000000000000000000000000000000000000000000000000000000f"), + (H256::from_low_u64_be(16), "0x0000000000000000000000000000000000000000000000000000000000000010"), + (H256::from_low_u64_be(1_000), "0x00000000000000000000000000000000000000000000000000000000000003e8"), + (H256::from_low_u64_be(100_000), "0x00000000000000000000000000000000000000000000000000000000000186a0"), + (H256::from_low_u64_be(u64::max_value()), "0x000000000000000000000000000000000000000000000000ffffffffffffffff"), ]; for (number, expected) in tests { diff --git a/substrate/core/rpc/src/chain/tests.rs b/substrate/core/rpc/src/chain/tests.rs index 5dcd2d0e21..f6c8aa4b79 100644 --- a/substrate/core/rpc/src/chain/tests.rs +++ b/substrate/core/rpc/src/chain/tests.rs @@ -17,7 +17,7 @@ use super::*; use jsonrpc_macros::pubsub; use test_client::{self, TestClient}; -use test_client::runtime::{Block, Header}; +use test_client::runtime::{H256, Block, Header}; use consensus::BlockOrigin; #[test] @@ -33,7 +33,7 @@ fn should_return_header() { assert_matches!( client.header(Some(client.client.genesis_hash()).into()), Ok(Some(ref x)) if x == &Header { - parent_hash: 0.into(), + parent_hash: H256::from_low_u64_be(0), number: 0, state_root: x.state_root.clone(), extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), @@ -44,7 +44,7 @@ fn should_return_header() { assert_matches!( client.header(None.into()), Ok(Some(ref x)) if x == &Header { - parent_hash: 0.into(), + parent_hash: H256::from_low_u64_be(0), number: 0, state_root: x.state_root.clone(), extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), @@ -53,7 +53,7 @@ fn should_return_header() { ); assert_matches!( - client.header(Some(5.into()).into()), + client.header(Some(H256::from_low_u64_be(5)).into()), Ok(None) ); } @@ -107,7 +107,7 @@ fn should_return_a_block() { ); assert_matches!( - api.block(Some(5.into()).into()), + api.block(Some(H256::from_low_u64_be(5)).into()), Ok(None) ); } diff --git a/substrate/core/sr-primitives/src/generic/digest.rs b/substrate/core/sr-primitives/src/generic/digest.rs index 5d6aba3ab6..1b54f42134 100644 --- a/substrate/core/sr-primitives/src/generic/digest.rs +++ b/substrate/core/sr-primitives/src/generic/digest.rs @@ -227,7 +227,7 @@ mod tests { logs: vec![ DigestItem::AuthoritiesChange(vec![1]), DigestItem::ChangesTrieRoot(4), - DigestItem::Seal(1, 15.into()), + DigestItem::Seal(1, Signature::from_low_u64_be(15)), DigestItem::Other(vec![1, 2, 3]), ], }; diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 204a87d33d..00c1df5af4 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/core/transaction-pool/graph/src/pool.rs b/substrate/core/transaction-pool/graph/src/pool.rs index 923a4f2295..f69aa1d24d 100644 --- a/substrate/core/transaction-pool/graph/src/pool.rs +++ b/substrate/core/transaction-pool/graph/src/pool.rs @@ -314,7 +314,7 @@ fn fire_events( mod tests { use super::*; use futures::Stream; - use test_runtime::{Block, Extrinsic, Transfer}; + use test_runtime::{Block, Extrinsic, Transfer, H256}; #[derive(Debug, Default)] struct TestApi; @@ -352,7 +352,7 @@ mod tests { /// Returns a block hash given the block id. fn block_id_to_hash(&self, at: &BlockId) -> Result>, Self::Error> { Ok(match at { - BlockId::Number(num) => Some((*num).into()), + BlockId::Number(num) => Some(H256::from_low_u64_be(*num)), BlockId::Hash(_) => None, }) } @@ -379,8 +379,8 @@ mod tests { // when let hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, })).unwrap(); @@ -394,8 +394,8 @@ mod tests { // given let pool = pool(); let uxt = uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, }); @@ -419,21 +419,21 @@ mod tests { // when let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, })).unwrap(); let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 1, })).unwrap(); // future doesn't count let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 3, })).unwrap(); @@ -455,20 +455,20 @@ mod tests { // given let pool = pool(); let hash1 = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, })).unwrap(); let hash2 = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 1, })).unwrap(); let hash3 = pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 3, })).unwrap(); @@ -494,8 +494,8 @@ mod tests { // given let pool = pool(); let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, })).unwrap(); @@ -510,7 +510,7 @@ mod tests { // then let mut stream = watcher.into_stream().wait(); assert_eq!(stream.next(), Some(Ok(::watcher::Status::Ready))); - assert_eq!(stream.next(), Some(Ok(::watcher::Status::Finalised(2.into())))); + assert_eq!(stream.next(), Some(Ok(::watcher::Status::Finalised(H256::from_low_u64_be(2))))); assert_eq!(stream.next(), None); } @@ -519,8 +519,8 @@ mod tests { // given let pool = pool(); let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 1, })).unwrap(); @@ -529,8 +529,8 @@ mod tests { // when pool.submit_one(&BlockId::Number(0), uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, })).unwrap(); @@ -547,8 +547,8 @@ mod tests { // given let pool = pool(); let uxt = uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, }); @@ -571,8 +571,8 @@ mod tests { // given let pool = pool(); let uxt = uxt(Transfer { - from: 1.into(), - to: 2.into(), + from: H256::from_low_u64_be(1), + to: H256::from_low_u64_be(2), amount: 5, nonce: 0, }); diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index f7ce6caae3..00530858ca 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/substrate/srml/contract/src/exec.rs b/substrate/srml/contract/src/exec.rs index af900081d3..44dacb2799 100644 --- a/substrate/srml/contract/src/exec.rs +++ b/substrate/srml/contract/src/exec.rs @@ -653,7 +653,7 @@ mod tests { fn insert(&mut self, f: impl Fn(MockCtx) -> VmExecResult + 'a) -> CodeHash { // Generate code hashes as monotonically increasing values. - let code_hash = self.counter.into(); + let code_hash = ::Hash::from_low_u64_be(self.counter); self.counter += 1; self.map.insert(code_hash, MockExecutable::new(f));