sp_test_primitives/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
21
22extern crate alloc;
23
24use codec::{Decode, DecodeWithMemTracking, Encode};
25
26pub use sp_application_crypto;
27use sp_application_crypto::sr25519;
28
29use alloc::vec::Vec;
30pub use sp_core::{hash::H256, RuntimeDebug};
31use sp_runtime::traits::{BlakeTwo256, ExtrinsicLike, Verify};
32
33#[derive(
35 Clone, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, RuntimeDebug, scale_info::TypeInfo,
36)]
37pub enum Extrinsic {
38 IncludeData(Vec<u8>),
39 StorageChange(Vec<u8>, Option<Vec<u8>>),
40}
41
42#[cfg(feature = "serde")]
43impl serde::Serialize for Extrinsic {
44 fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error>
45 where
46 S: ::serde::Serializer,
47 {
48 self.using_encoded(|bytes| seq.serialize_bytes(bytes))
49 }
50}
51
52impl ExtrinsicLike for Extrinsic {
53 fn is_signed(&self) -> Option<bool> {
54 if let Extrinsic::IncludeData(_) = *self {
55 Some(false)
56 } else {
57 Some(true)
58 }
59 }
60
61 fn is_bare(&self) -> bool {
62 if let Extrinsic::IncludeData(_) = *self {
63 true
64 } else {
65 false
66 }
67 }
68}
69
70pub type AccountSignature = sr25519::Signature;
72pub type AccountId = <AccountSignature as Verify>::Signer;
74pub type Hash = H256;
76pub type BlockNumber = u64;
78pub type Nonce = u64;
80pub type DigestItem = sp_runtime::generic::DigestItem;
82pub type Digest = sp_runtime::generic::Digest;
84pub type Block = sp_runtime::generic::Block<Header, Extrinsic>;
86pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;