-
Notifications
You must be signed in to change notification settings - Fork 52
/
run-c-kzg-4844-tests.sh
executable file
·177 lines (136 loc) · 3.72 KB
/
run-c-kzg-4844-tests.sh
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
#!/bin/bash
set -e
print_msg () {
echo "[*]" "$1"
}
###################### parallel & backend configuration ######################
parallel=false
backend="unknown"
while [[ -n $# ]]; do
case $1 in
-p|--parallel)
parallel=true
;;
blst|arkworks|arkworks3|mcl|zkcrypto|constantine)
backend="$1"
;;
*)
break
;;
esac
shift
done
if [ "$backend" == "unknown" ]; then
echo "Unknown backend: $backend"
exit 1
fi
###################### building static libs ######################
print_msg "Compiling rust-kzg-$backend"
cd $backend
if [[ "$parallel" = true ]]; then
print_msg "Using parallel version"
cargo rustc --release --crate-type=staticlib --features=parallel
else
print_msg "Using non-parallel version"
cargo rustc --release --crate-type=staticlib
fi
rm -f ../target/release/rust_kzg_$backend.a
mv ../target/release/librust_kzg_$backend.a ../target/release/rust_kzg_$backend.a
###################### cloning c-kzg-4844 ######################
print_msg "Removing existing c-kzg-4844"
rm -rf c-kzg-4844
print_msg "Cloning c-kzg-4844"
git clone https://github.com/ethereum/c-kzg-4844.git
cd c-kzg-4844 || exit
git -c advice.detachedHead=false checkout "$C_KZG_4844_GIT_HASH"
git submodule update --init
print_msg "Applying patches and building blst"
cd src
export CFLAGS="-Ofast -fno-builtin-memcpy -fPIC -Wall -Wextra -Werror"
make blst
unset CFLAGS
cd ..
###################### detecting os ######################
case $(uname -s) in
"Linux")
CSHARP_PLATFORM=linux-x64
CLANG_PLATFORM=x86_64-linux
;;
"Darwin")
CSHARP_PLATFORM=osx-x64
CLANG_PLATFORM=x86_64-darwin
;;
*)
echo "FAIL: unsupported OS"
exit 1
;;
esac
###################### dotnet tests ######################
print_msg "Patching dotnet binding"
git apply < ../csharp.patch
cd bindings/csharp || exit
print_msg "Building dotnet"
make -B ckzg CSHARP_PLATFORM=$CSHARP_PLATFORM CLANG_PLATFORM=$CLANG_PLATFORM
dotnet restore
print_msg "Running dotnet tests"
dotnet test -c release --no-restore
cd ../..
###################### rust tests ######################
print_msg "Patching rust binding"
git apply < ../rust.patch
cd bindings/rust || exit
print_msg "Running rust tests"
cargo test --release
cd ../..
print_msg "Rebuilding blst"
cd src
export CFLAGS="-Ofast -fno-builtin-memcpy -fPIC -Wall -Wextra -Werror"
make blst
unset CFLAGS
cd ..
###################### python tests ######################
print_msg "Patching python binding"
git apply < ../python.patch
cd bindings/python || exit
print_msg "Running python tests"
make
cd ../..
###################### java tests ######################
print_msg "Patching java binding"
git apply < ../java.patch
cd bindings/java || exit
print_msg "Running java tests"
make build test
cd ../..
###################### nodejs tests ######################
print_msg "Patching nodejs binding"
git apply < ../nodejs.patch
cd bindings/node.js || exit
print_msg "Running nodejs tests"
make
cd ../..
###################### go tests ######################
print_msg "Patching go binding"
git apply < ../go.patch
cd bindings/go || exit
print_msg "Running go tests"
CGO_CFLAGS="-O2 -D__BLST_PORTABLE__" go test
cd ../..
###################### nim tests ######################
if [ "$backend" != "constantine" ]; then
print_msg "Patching nim binding"
git apply < ../nim.patch
print_msg "Installing nim dependencies"
nimble install -y stew
nimble install -y unittest2
nimble install -y yaml
print_msg "Running nim tests"
cd bindings/nim || exit
nim test
cd ../../..
else
print_msg "Currently, nim bindings are not supported for constantine backend"
fi
###################### cleaning up ######################
print_msg "Cleaning up"
rm -rf c-kzg-4844