-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·192 lines (156 loc) · 5.19 KB
/
test.sh
File metadata and controls
executable file
·192 lines (156 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
set -e
source /root/.docker_bashrc
export PATH=~/.cargo/bin:$PATH
export SGX_MODE=HW
export RUSTFLAGS=-Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3
ANONIFY_ROOT=/root/anonify
ANONIFY_TAG=v0.5.11
#
# Setup Tests
#
dirpath=$(cd $(dirname $0) && pwd)
cd "${dirpath}/.."
if [ ! -d ${ANONIFY_ROOT}/anonify-contracts ]; then
git clone --depth 1 -b $ANONIFY_TAG https://github.com/LayerXcom/anonify-contracts
else
cd ${ANONIFY_ROOT}/anonify-contracts
tag_id=`git show $ANONIFY_TAG | grep commit | cut -f 2 -d ' '`
current_commit_id=`git rev-parse HEAD`
if [ $tag_id = $current_commit_id ]; then
echo "already cloned /anonify-contracts(skipped)"
else
echo "already exists /anonify-contracts directory, but doesn't match commit id with specified by tag"
exit 1
fi
fi
cd ${ANONIFY_ROOT}
solc -o contract-build --bin --abi --optimize --overwrite \
anonify-contracts/contracts/AnonifyWithTreeKem.sol \
anonify-contracts/contracts/AnonifyWithEnclaveKey.sol \
anonify-contracts/contracts/Factory.sol
# Deploy a FACTORY Contract
cd ${ANONIFY_ROOT}/anonify-contracts/deployer
export FACTORY_CONTRACT_ADDRESS=$(cargo run factory)
cd ${ANONIFY_ROOT}/frame/types
cargo build
# Generate key-vault's signed.so and measurement.txt
echo "Integration testing..."
cd ${ANONIFY_ROOT}/scripts
export ENCLAVE_PKG_NAME=key_vault
make DEBUG=1 ENCLAVE_DIR=example/key-vault/enclave
#
# Tests for enclave key
#
# Integration Tests
export ENCLAVE_PKG_NAME=erc20
# make with backup disabled
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave FEATURE_FLAGS="runtime_enabled,enclave_key"
cd ${ANONIFY_ROOT}/tests/integration
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_enclave_key -- --nocapture
# ERC20 Application Tests
function exec_sr_enclave_key_node_tests() {
for N in "$@"
do
cd ${ANONIFY_ROOT}/anonify-contracts/deployer
cargo run anonify_ek "$FACTORY_CONTRACT_ADDRESS"
cd ${ANONIFY_ROOT}/nodes/state-runtime/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo test "$N" -- --nocapture
sleep 1
done
}
exec_sr_enclave_key_node_tests test_health_check \
test_enclave_key_evaluate_access_policy_by_user_id_field \
test_enclave_key_multiple_messages \
test_enclave_key_skip_invalid_event \
test_enclave_key_node_recovery \
test_enclave_key_join_group_then_handshake \
test_enclave_key_duplicated_out_of_order_request_from_same_user
# Secret Backup Application Tests
cd ${ANONIFY_ROOT}/scripts
export ENCLAVE_PKG_NAME=erc20
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave
cd ${ANONIFY_ROOT}/nodes/key-vault
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_health_check -- --nocapture
function exec_kv_enclave_key_node_tests() {
for N in "$@"
do
cd ${ANONIFY_ROOT}/anonify-contracts/deployer
cargo run anonify_ek "$FACTORY_CONTRACT_ADDRESS"
cd ${ANONIFY_ROOT}/nodes/key-vault
RUST_BACKTRACE=1 RUST_LOG=debug cargo test "$N" -- --nocapture
sleep 1
done
}
exec_kv_enclave_key_node_tests test_health_check \
test_enclave_key_backup
#
# Tests for treekem
#
# Integration Tests
cd ${ANONIFY_ROOT}/scripts
export ENCLAVE_PKG_NAME=erc20
# make with backup disabled
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave FEATURE_FLAGS="runtime_enabled,treekem"
cd ${ANONIFY_ROOT}/tests/integration
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_treekem --no-default-features -- --nocapture
# ERC20 Application Tests
function exec_sr_treekem_node_tests() {
for N in "$@"
do
cd ${ANONIFY_ROOT}/anonify-contracts/deployer
cargo run anonify_tk "$FACTORY_CONTRACT_ADDRESS"
cd ${ANONIFY_ROOT}/nodes/state-runtime/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo test "$N" -- --nocapture
sleep 1
done
}
exec_sr_treekem_node_tests \
test_treekem_evaluate_access_policy_by_user_id_field \
test_treekem_multiple_messages \
test_treekem_skip_invalid_event \
test_treekem_join_group_then_handshake \
test_treekem_duplicated_out_of_order_request_from_same_user
# Secret Backup Application Tests
cd ${ANONIFY_ROOT}/scripts
export ENCLAVE_PKG_NAME=erc20
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave FEATURE_FLAGS="runtime_enabled,backup-enable,treekem"
function exec_kv_treekem_node_tests() {
for N in "$@"
do
cd ${ANONIFY_ROOT}/anonify-contracts/deployer
cargo run anonify_tk "$FACTORY_CONTRACT_ADDRESS"
cd ${ANONIFY_ROOT}/nodes/key-vault
RUST_BACKTRACE=1 RUST_LOG=debug cargo test "$N" -- --nocapture
sleep 1
done
}
exec_kv_treekem_node_tests \
test_treekem_backup_path_secret \
test_treekem_recover_without_key_vault \
test_treekem_manually_backup_all \
test_treekem_manually_recover_all
#
# Unit Tests
#
echo "Unit testing..."
export ENCLAVE_PKG_NAME=units
cd ${ANONIFY_ROOT}/scripts
# make with backup disabled
make DEBUG=1 TEST=1 ENCLAVE_DIR=tests/units/enclave FEATURE_FLAGS="runtime_enabled"
cd ${ANONIFY_ROOT}
RUST_BACKTRACE=1 RUST_LOG=debug TEST=1 cargo test \
-p unit-tests-host \
-p frame-runtime \
-p frame-retrier \
-p frame-sodium -- --nocapture
#
# Compile Checks
#
./scripts/build-cli.sh
cd ${ANONIFY_ROOT}/example/erc20/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo c
cd ${ANONIFY_ROOT}/example/key-vault/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo c
cd ${ANONIFY_ROOT}/example/wallet
RUST_BACKTRACE=1 RUST_LOG=debug cargo c