Skip to content

Commit 4d045e5

Browse files
author
Yucong Sun
committed
Try to install libra_dev into system directory
1 parent bb8d780 commit 4d045e5

File tree

6 files changed

+66
-18
lines changed

6 files changed

+66
-18
lines changed

.circleci/config.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
build-executor:
55
docker:
6-
- image: circleci/rust:stretch
6+
- image: circleci/rust:buster
77
resource_class: 2xlarge
88

99
jobs:
@@ -14,20 +14,47 @@ jobs:
1414
- run:
1515
name: Setup
1616
command: |
17-
sudo sh -c 'echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list'
18-
sudo apt-get update
19-
sudo apt-get -t stretch-backports install cmake python3-dev python3-venv clang llvm libjemalloc-dev
17+
sudo apt-get update && sudo apt-get upgrade -y
18+
sudo apt-get install cmake python3-dev python3-venv clang llvm libjemalloc-dev librocksdb-dev
2019
- run:
21-
name: Build everything
20+
name: Build libra-dev
2221
command: |
2322
./build.sh
23+
- run:
24+
name: Install libra-dev
25+
command: |
26+
sudo cp libra-dev/target/debug/liblibra_dev.so /usr/lib
27+
- run:
28+
name: Test C++ client
29+
background: true
30+
when: always
31+
shell: /bin/sh
32+
command: |
33+
cd cpp
34+
./build.sh && ./test.sh
35+
touch test-done
2436
- run:
2537
name: Test Rust Client
38+
background: true
39+
when: always
40+
shell: /bin/sh
2641
command: |
2742
cd rust
2843
./test.sh
44+
touch test-done
2945
- run:
3046
name: Test Python stuff
47+
background: true
48+
when: always
49+
shell: /bin/sh
3150
command: |
3251
cd python
3352
./test.sh
53+
touch test-done
54+
- run:
55+
name: Wait for everything
56+
when: always
57+
command: |
58+
while [ ! -f cpp/test-done ]; do sleep 1; done
59+
while [ ! -f rust/test-done ]; do sleep 1; done
60+
while [ ! -f python/test-done ]; do sleep 1; done

build.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,3 @@ cd ..
1111
cd rust
1212
cargo build
1313
cd ..
14-
15-
# C Stuff
16-
rm -rf build
17-
mkdir build
18-
cd build
19-
cmake ..
20-
make VERBOSE=1
21-
# Test!
22-
./cpp/cpp-client
23-
cd ..

cpp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

cpp/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# C Stuff
5+
rm -rf build
6+
mkdir build
7+
cd build || exit
8+
cmake ..
9+
make VERBOSE=1
10+
cd ..

cpp/main.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ byte_string hex2bin(const std::string &in) {
3434
return result;
3535
}
3636

37+
constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',
38+
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
39+
40+
std::string hexStr(unsigned char *data, int len) {
41+
std::string s(len * 2, ' ');
42+
for (int i = 0; i < len; ++i) {
43+
s[2 * i] = hexmap[(data[i] & 0xF0) >> 4];
44+
s[2 * i + 1] = hexmap[data[i] & 0x0F];
45+
}
46+
return s;
47+
}
48+
3749
int main() {
3850
std::basic_string<unsigned char> blob = hex2bin(
3951
"020000002100000001674deac5e7fca75f00ca92b1ba3697f5f01ef585011beea7b361150f4504638f0800000002000000000000002100000001a208df134fefed8442b1f01fab59071898f5a1af5164e12c594de55a7004a91c8e0000002000000036ccb9ba8b4f0cd1f3e2d99338806893dff7478c69acee9b8e1247c053783a4800e876481700000000000200000000000000200000000b14ed4f5af8f8f077c7ec4313c6d395b9a7eb5f41eab9ec15367215ca9e420a01000000000000002000000032f56f77b09773aa64c78ee39943da7ec73f91cd757e325098e11b3edc4eccb10100000000000000"
@@ -44,21 +56,24 @@ int main() {
4456
<< std::endl
4557
<< "sequence: " << account_resource.sequence
4658
<< std::endl
59+
<< "authentication_key: " << hexStr(account_resource.authentication_key, 32)
60+
<< std::endl
4761
<< "delegated_key_rotation_capability: " << account_resource.delegated_key_rotation_capability
62+
<< std::endl
63+
<< "delegated_withdrawal_capability: " << account_resource.delegated_withdrawal_capability
4864
<< std::endl;
4965

5066
struct CEventHandle sent_events = account_resource.sent_events;
5167
std::cout << "sent events count: " << sent_events.count << std::endl;
52-
std::cout << std::endl;
5368

54-
std::cout << "sent events key:" << sent_events.key;
69+
std::cout << "sent events key:" << hexStr(sent_events.key, 32);
5570
std::cout << std::endl;
5671

5772
struct CEventHandle received_events = account_resource.received_events;
5873
std::cout << "received events count: " << received_events.count;
5974
std::cout << std::endl;
6075

61-
std::cout << "sent events key:" << received_events.key;
76+
std::cout << "sent events key:" << hexStr(received_events.key, 32);
6277
std::cout << std::endl;
6378

6479

cpp/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Test!
5+
./build/cpp-client

0 commit comments

Comments
 (0)