mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
break sp-api dependency cycle (#4352)
* move benches into tests, ignore non-passing doctests * Rename sr-api folder * Move test-primitives to primitives, use that for sp-api doctests
This commit is contained in:
committed by
Bastian Köcher
parent
f6f0f1cc16
commit
8721d98dd6
@@ -0,0 +1,78 @@
|
||||
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! The Substrate test primitives to share
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
use app_crypto::sr25519;
|
||||
pub use app_crypto;
|
||||
|
||||
pub use primitives::{hash::H256, RuntimeDebug};
|
||||
use sp_runtime::traits::{BlakeTwo256, Verify, Extrinsic as ExtrinsicT,};
|
||||
|
||||
/// Extrinsic for test-runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
pub enum Extrinsic {
|
||||
IncludeData(Vec<u8>),
|
||||
StorageChange(Vec<u8>, Option<Vec<u8>>),
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl serde::Serialize for Extrinsic {
|
||||
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer {
|
||||
self.using_encoded(|bytes| seq.serialize_bytes(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl ExtrinsicT for Extrinsic {
|
||||
type Call = Extrinsic;
|
||||
type SignaturePayload = ();
|
||||
|
||||
fn is_signed(&self) -> Option<bool> {
|
||||
if let Extrinsic::IncludeData(_) = *self {
|
||||
Some(false)
|
||||
} else {
|
||||
Some(true)
|
||||
}
|
||||
}
|
||||
|
||||
fn new(call: Self::Call, _signature_payload: Option<Self::SignaturePayload>) -> Option<Self> {
|
||||
Some(call)
|
||||
}
|
||||
}
|
||||
|
||||
/// The signature type used by accounts/transactions.
|
||||
pub type AccountSignature = sr25519::Signature;
|
||||
/// An identifier for an account on this system.
|
||||
pub type AccountId = <AccountSignature as Verify>::Signer;
|
||||
/// A simple hash type for all our hashing.
|
||||
pub type Hash = H256;
|
||||
/// The block number type used in this runtime.
|
||||
pub type BlockNumber = u64;
|
||||
/// Index of a transaction.
|
||||
pub type Index = u64;
|
||||
/// The item of a block digest.
|
||||
pub type DigestItem = sp_runtime::generic::DigestItem<H256>;
|
||||
/// The digest of a block.
|
||||
pub type Digest = sp_runtime::generic::Digest<H256>;
|
||||
/// A test block.
|
||||
pub type Block = sp_runtime::generic::Block<Header, Extrinsic>;
|
||||
/// A test block's header.
|
||||
pub type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
|
||||
Reference in New Issue
Block a user