Commit 0427c87c authored by Hero Bird's avatar Hero Bird
Browse files

[pdsl_tests] Fix pDSL tests

We should maybe even remove this sub crate in favor of the example crates
parent a3d8bb6d
......@@ -3,30 +3,22 @@ name = "pdsl_tests"
version = "0.1.0"
authors = ["Robin Freyler <robbepop@web.de>"]
edition = "2018"
# license = "MIT/Apache-2.0"
description = "Tests for the Substrate smart constracts Rust eDSL"
license = "GPL-3.0"
# readme = "README.md"
# description = "Tests for the Substrate smart constracts Rust eDSL"
# repository = "https://github.com/robbepop/stevia"
# documentation = "https://docs.rs/stevia"
# repository = "https://github.com/robbepop/pdsl"
# documentation = "https://docs.rs/pdsl"
# homepage =
# keywords = ["smt", "solver", "formal methods"]
# categories = ["science"]
# keywords = []
# categories = []
[lib]
crate-type = ["cdylib"]
name = "pdsl_tests"
[dependencies]
pdsl = { path = "../pdsl_derive", package = "pdsl_derive" }
pdsl_core = { path = "../pdsl_core" }
parity-codec = { version = "2.0.4", default-features = false }
parity-codec-derive = { version = "2.0.4", default-features = false }
wee_alloc = "0.4"
parity-codec = { version = "2.2", default-features = false, features = ["derive"] }
[features]
test-env = ["pdsl_core/test-env"]
#![feature(alloc_error_handler)]
#![feature(alloc)]
#![no_std]
pub mod incrementer {
use pdsl_core::env::{Env, ContractEnv};
use pdsl_core::storage::{Key, cell::SyncCell};
#[derive(parity_codec_derive::Encode, parity_codec_derive::Decode)]
use pdsl_core::{
env::{Env, ContractEnv},
storage::{
alloc,
Key,
cell::SyncCell,
},
};
#[derive(parity_codec::Encode, parity_codec::Decode)]
enum Action {
Inc(u32),
Get,
}
const COUNTER_KEY: Key = Key([1; 32]);
const ALLOC_KEY: Key = Key([0x0; 32]);
#[no_mangle]
pub extern "C" fn deploy() {
unsafe {
SyncCell::new_unchecked(COUNTER_KEY).set(0)
let mut alloc = alloc::ForwardAlloc::from_raw_parts(ALLOC_KEY);
SyncCell::new_using_alloc(&mut alloc).set(0)
}
}
......@@ -28,7 +34,8 @@ pub mod incrementer {
let action = Action::decode(&mut &input[..]).unwrap();
let mut counter = unsafe {
SyncCell::<u32>::new_unchecked(COUNTER_KEY)
let mut alloc = alloc::ForwardAlloc::from_raw_parts(ALLOC_KEY);
SyncCell::new_using_alloc(&mut alloc)
};
match action {
......
Markdown is supported
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