Commit a7471310 authored by Hero Bird's avatar Hero Bird
Browse files

[pdsl] Remove pdsl_tests

parent bfcafb54
......@@ -3,7 +3,6 @@
members = [
"pdsl_core",
# "pdsl_derive",
"pdsl_tests",
]
exclude = [
"examples/",
......
[package]
name = "pdsl_tests"
version = "0.1.0"
authors = ["Robin Freyler <robbepop@web.de>"]
edition = "2018"
description = "Tests for the Substrate smart constracts Rust eDSL"
license = "GPL-3.0"
# readme = "README.md"
# repository = "https://github.com/robbepop/pdsl"
# documentation = "https://docs.rs/pdsl"
# homepage =
# keywords = []
# categories = []
[lib]
crate-type = ["cdylib"]
name = "pdsl_tests"
[dependencies]
pdsl_core = { path = "../pdsl_core" }
parity-codec = { version = "2.2", default-features = false, features = ["derive"] }
[features]
test-env = ["pdsl_core/test-env"]
#![no_std]
pub mod incrementer {
use pdsl_core::{
env::{Env, ContractEnv},
storage::{
alloc,
Key,
cell::SyncCell,
},
};
#[derive(parity_codec::Encode, parity_codec::Decode)]
enum Action {
Inc(u32),
Get,
}
const ALLOC_KEY: Key = Key([0x0; 32]);
#[no_mangle]
pub extern "C" fn deploy() {
unsafe {
let mut alloc = alloc::BumpAlloc::from_raw_parts(ALLOC_KEY);
SyncCell::new_using_alloc(&mut alloc).set(0)
}
}
#[no_mangle]
pub extern "C" fn call() {
use parity_codec::{Decode, Encode};
let input = ContractEnv::input();
let action = Action::decode(&mut &input[..]).unwrap();
let mut counter = unsafe {
let mut alloc = alloc::BumpAlloc::from_raw_parts(ALLOC_KEY);
SyncCell::new_using_alloc(&mut alloc)
};
match action {
Action::Inc(by) => {
counter.mutate_with(|counter| *counter += by);
}
Action::Get => {
ContractEnv::return_(
&counter.get().unwrap_or(&0).encode()
);
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment