Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samplecode/kvdb-memdb/enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ default = []

[dependencies]
elastic-array = { path = "../../../third_party/elastic-array", default-features = false }
parity-bytes = { path = "../../../third_party/parity-common/parity-bytes", default-features = false }
kvdb = { path = "../../../third_party/parity-common/kvdb" }

[target.'cfg(not(target_env = "sgx"))'.dependencies]
sgx_types = { path = "../../../sgx_types" }
Expand Down
28 changes: 28 additions & 0 deletions samplecode/kvdb-memdb/enclave/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern crate sgx_types;
extern crate sgx_tstd as std;

extern crate elastic_array;
extern crate parity_bytes;

use sgx_types::*;
use std::string::String;
Expand All @@ -46,6 +47,7 @@ use std::io::{self, Write};
use std::slice;

use elastic_array::ElasticArray2;
use parity_bytes::BytesRef;

#[no_mangle]
pub extern "C" fn say_something(some_string: *const u8, some_len: usize) -> sgx_status_t {
Expand Down Expand Up @@ -87,6 +89,32 @@ pub extern "C" fn say_something(some_string: *const u8, some_len: usize) -> sgx_
let r: &[u8] = &bytes;
assert_eq!(r, &[1, 3, 4, 2]);

//test parity_byte import
let mut data1 = vec![0, 0, 0];
let mut data2 = vec![0, 0, 0];
let mut data3 = vec![0, 0, 0];
let (res1, res2, res3) = {
let mut bytes1 = BytesRef::Flexible(&mut data1);
let mut bytes2 = BytesRef::Flexible(&mut data2);
let mut bytes3 = BytesRef::Flexible(&mut data3);

// when
let res1 = bytes1.write(1, &[1, 1, 1]);
let res2 = bytes2.write(3, &[1, 1, 1]);
let res3 = bytes3.write(5, &[1, 1, 1]);
(res1, res2, res3)
};

// then
assert_eq!(&data1, &[0, 1, 1, 1]);
assert_eq!(res1, 3);

assert_eq!(&data2, &[0, 0, 0, 1, 1, 1]);
assert_eq!(res2, 3);

assert_eq!(&data3, &[0, 0, 0, 0, 0, 1, 1, 1]);
assert_eq!(res3, 5);


sgx_status_t::SGX_SUCCESS
}
16 changes: 16 additions & 0 deletions third_party/parity-common/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true
[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=120
insert_final_newline=true

[*.{yml,sh}]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf
21 changes: 21 additions & 0 deletions third_party/parity-common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**/target/

**/Cargo.lock

**/*.rs.bk

*.o
*.so
*.rlib
*.dll
.gdb_history

*.exe

.DS_Store

.idea
.vscode
*.iml
*.swp
*.swo
26 changes: 26 additions & 0 deletions third_party/parity-common/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: rust
branches:
only:
- master
matrix:
include:
- os: linux
rust: stable
- os: linux
rust: beta
- os: linux
rust: nightly
- os: osx
rust: stable
allow_failures:
- rust: nightly
script:
- cargo check --all --tests
- cargo build --all
- cargo test --all --exclude uint --exclude fixed-hash
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then cd parity-bytes/ && cargo build --no-default-features && cd ..;
fi
- cd fixed-hash/ && cargo test --all-features && cd ..
- cd uint/ && cargo test --features=std,quickcheck --release && cd ..
- cd plain_hasher/ && cargo test --no-default-features && cd ..
- cd parity-util-mem/ && cargo test --features=estimate-heapsize && cd ..
21 changes: 21 additions & 0 deletions third_party/parity-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[workspace]
members = [
"fixed-hash",
"keccak-hash",
"kvdb",
"kvdb-memorydb",
"kvdb-rocksdb",
"parity-bytes",
"parity-crypto",
"parity-path",
"plain_hasher",
"rlp",
"transaction-pool",
"trace-time",
"triehash",
"uint",
"parity-util-mem",
"primitive-types",
"ethereum-types",
"ethbloom",
]
Loading