Introduce toy runtime for testing inside substrate. (#66)

* Introduce simple blockchain runtime for substrate tests.

* Remove bad files.

* Add needed wasm binaries.

* Refactoring.

- Repot files in test-runtime.
- Rename troublesome `Joiner::join` to `Joiner::and`.
- Rework `Slicable` to dedup code.

* More fixes and refactoring

* Rebuild substrate test wasm.

* Fix merge errors.

* Rename the disasterously named `to_vec` to `encode`.

Also rename `as_slice_then` to `with_encoded`.

* Tests for toy runtime.

* Fix doc nit
This commit is contained in:
Gav Wood
2018-02-09 13:24:30 +01:00
committed by GitHub
parent a00d0e75fd
commit dec6e82387
65 changed files with 1923 additions and 496 deletions
+8 -14
View File
@@ -19,28 +19,22 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate substrate_runtime_std as rstd;
#[macro_use] extern crate substrate_runtime_io as runtime_io;
extern crate substrate_runtime_support as runtime_support;
#[macro_use]
extern crate substrate_runtime_io as runtime_io;
#[cfg(feature = "std")]
extern crate rustc_hex;
#[cfg(feature = "std")] extern crate rustc_hex;
extern crate substrate_codec as codec;
extern crate substrate_primitives;
#[cfg(feature = "std")] #[macro_use] extern crate substrate_primitives as primitives;
extern crate polkadot_primitives;
#[cfg(test)]
#[macro_use]
extern crate hex_literal;
#[cfg(test)] #[macro_use] extern crate hex_literal;
#[macro_use]
pub mod support;
pub mod environment;
pub mod runtime;
pub mod api;
#[cfg(feature = "std")]
pub mod genesismap;
#[cfg(feature = "std")] pub mod genesismap;
/// Type definitions and helpers for transactions.
pub mod transaction {
@@ -72,7 +66,7 @@ pub mod transaction {
///
/// On failure, return the transaction back.
pub fn check(tx: UncheckedTransaction) -> Result<CheckedTransaction, UncheckedTransaction> {
let msg = ::codec::Slicable::to_vec(&tx.transaction);
let msg = ::codec::Slicable::encode(&tx.transaction);
if ::runtime_io::ed25519_verify(&tx.signature.0, &msg, &tx.transaction.signed) {
Ok(CheckedTransaction(tx))
} else {