Debian Codegraph @

test.sh

raw symbols SCIP
1 #!/bin/sh
2
3 hashcash="../hashcash -u -t 040404"
4 sha1="../sha1"
5 mkdir -p test
6 cd test
7
8 #v=1
9 test=1
10
11 ######################################################################
12
13 echo -n "test $test (-mb8) "
14 $hashcash -mqb8 [email protected] > stamp.$test
15 echo -n `cat stamp.$test` | $sha1 | sed 's/^\(..\).*/\1/' > res.$test
16 echo 00 > out.$test
17 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
18 test=`expr $test + 1`
19
20 ######################################################################
21
22 echo -n "test $test (-mb12) "
23 $hashcash -mqb12 [email protected] > stamp.$test
24 echo -n `cat stamp.$test` | $sha1 | sed 's/^\(...\).*/\1/' > res.$test
25 echo 000 > out.$test
26 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
27 test=`expr $test + 1`
28
29 ######################################################################
30
31 echo -n "test $test (-mb8 -mb12) "
32 $hashcash -mqb8 [email protected] -b12 [email protected] > stamp.$test
33 echo -n `head -1 stamp.$test` | $sha1 | sed 's/^\(..\).*/\1/' > res1.$test
34 echo 00 > out1.$test
35 echo -n `tail -1 stamp.$test` | $sha1 | sed 's/^\(...\).*/\1/' > res2.$test
36 echo 000 > out2.$test
37 diff -q res1.$test out1.$test 1> /dev/null 2>&1 && \
38 diff -q res2.$test out2.$test 1> /dev/null 2>&1 && echo ok || echo fail
39 test=`expr $test + 1`
40
41 ######################################################################
42
43 echo -n "test $test (-b10 partial) "
44 $hashcash -q -b10 < stamps
45 [ $? -eq 2 ] && echo ok || echo fail
46 test=`expr $test + 1`
47
48 ######################################################################
49
50 echo -n "test $test (-b15 insufficient) "
51 $hashcash -q -b15 < stamps
52 [ $? -eq 1 ] && echo ok || echo fail
53 test=`expr $test + 1`
54
55 ######################################################################
56
57 echo -n "test $test (-r partial) "
58 $hashcash -q -r '*@foo.com' < stamps
59 [ $? -eq 2 ] && echo ok || echo fail
60 test=`expr $test + 1`
61
62 ######################################################################
63
64 echo -n "test $test (-r no match) "
65 $hashcash -q -r '*@taz.com' < stamps
66 [ $? -eq 1 ] && echo ok || echo fail
67 test=`expr $test + 1`
68
69 ######################################################################
70
71 echo -n "test $test (-d not spent) "
72 cat > db.$test <<EOF
73 last_purged 700101000000
74 0:040402:[email protected]:0ace5ad5254b4e401036b5f0 2419200
75 EOF
76 cat > stamp.$test <<EOF
77 0:040402:[email protected]:be45eb4e586a3e08cf7c95c4
78 EOF
79 $hashcash -qd -f db.$test < stamp.$test
80 [ $? -eq 2 ] && echo ok || echo fail
81 test=`expr $test + 1`
82
83 ######################################################################
84
85 echo -n "test $test (-d spent) "
86 cat > db.$test <<EOF
87 last_purged 700101000000
88 0:040402:[email protected]:0ace5ad5254b4e401036b5f0 2419200
89 EOF
90 cat > stamp.$test <<EOF
91 0:040402:[email protected]:0ace5ad5254b4e401036b5f0
92 EOF
93 $hashcash -qd -f db.$test < stamp.$test
94 [ $? -eq 1 ] && echo ok || echo fail
95 test=`expr $test + 1`
96
97 ######################################################################
98
99 echo -n "test $test (-w) "
100 cat > stamps <<EOF
101 0:050403:[email protected]:1f0986777f16f66a53241ec3
102 0:030404:[email protected]:23d5ea11c43287d58ea6a63f
103 0:040402:[email protected]:0ace5ad5254b4e401036b5f0
104 0:040402:[email protected]:be45eb4e586a3e08cf7c95c4
105 0:040404:[email protected]:20056ff4e877027ef8ba55eb
106 EOF
107
108 cat > out.$test <<EOF
109 5
110 5
111 5
112 12
113 6
114 EOF
115 #if [ $v -ne "" ]; then echo; endif
116 [ $v ] && echo && echo "$hashcash -wq < stamps > res.$test"
117 $hashcash -wq < stamps > res.$test
118 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
119 test=`expr $test + 1`
120
121 ######################################################################
122
123 echo -n "test $test (-wb10 one sufficient) "
124 cat > stamp.$test <<EOF
125 0:040402:[email protected]:be45eb4e586a3e08cf7c95c4
126 EOF
127
128 cat > out.$test <<EOF
129 12
130 EOF
131 #if [ $v -ne "" ]; then echo; endif
132 [ $v ] && echo && echo "$hashcash -wq < stamp.$test > res.$test"
133 $hashcash -wqb10 < stamp.$test > res.$test
134 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
135 test=`expr $test + 1`
136
137 ######################################################################
138
139 echo -n "test $test (-wn) "
140 cat > out.$test <<EOF
141 [email protected] 5
142 [email protected] 5
143 [email protected] 5
144 [email protected] 12
145 [email protected] 6
146 EOF
147
148 $hashcash -wnq < stamps > res.$test
149 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
150 test=`expr $test + 1`
151
152 ######################################################################
153
154 echo -n "test $test (-n) "
155 cat > out.$test <<EOF
156 [email protected]
157 [email protected]
158 [email protected]
159 [email protected]
160 [email protected]
161 EOF
162
163 $hashcash -nq < stamps > res.$test
164 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
165 test=`expr $test + 1`
166
167 ######################################################################
168
169 echo -n "test $test (-nb10) "
170 cat > out.$test <<EOF
171 [email protected]
172 EOF
173
174 $hashcash -nqb10 < stamps > res.$test
175 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
176 test=`expr $test + 1`
177
178 ######################################################################
179
180 echo -n "test $test (-nr three match) "
181 cat > out.$test <<EOF
182 [email protected]
183 [email protected]
184 EOF
185
186 $hashcash -nq -r '*[email protected]' < stamps > res.$test
187 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
188 test=`expr $test + 1`
189
190 ######################################################################
191
192 echo -n "test $test (-l) "
193 cat > out.$test <<EOF
194 +31276800
195 -29030400
196 2419200
197 2419200
198 2592000
199 EOF
200
201 $hashcash -lq < stamps > res.$test
202 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
203 test=`expr $test + 1`
204
205 ######################################################################
206
207 echo -n "test $test (-nl) "
208 cat > out.$test <<EOF
209 [email protected] +31276800
210 [email protected] -29030400
211 [email protected] 2419200
212 [email protected] 2419200
213 [email protected] 2592000
214 EOF
215
216 $hashcash -nlq < stamps > res.$test
217 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
218 test=`expr $test + 1`
219
220 ######################################################################
221
222 echo -n "test $test (-wl) "
223 cat > out.$test <<EOF
224 5 +31276800
225 5 -29030400
226 5 2419200
227 12 2419200
228 6 2592000
229 EOF
230
231 $hashcash -wlq < stamps > res.$test
232 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
233 test=`expr $test + 1`
234
235 ######################################################################
236
237 echo -n "test $test (-nwl) "
238 cat > out.$test <<EOF
239 [email protected] 5 +31276800
240 [email protected] 5 -29030400
241 [email protected] 5 2419200
242 [email protected] 12 2419200
243 [email protected] 6 2592000
244 EOF
245
246 $hashcash -nwlq < stamps > res.$test
247 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
248 test=`expr $test + 1`
249
250 ######################################################################
251 # -c with -y
252 ######################################################################
253
254 echo -n "test $test (-cy -b10 match) "
255 $hashcash -cqy -b10 -r '*@foo.com' < stamps && echo ok || echo fail
256 test=`expr $test + 1`
257
258 ######################################################################
259
260 echo -n "test $test (-cy -b15 insufficient) "
261 $hashcash -cqy -b15 -r '*@foo.com' < stamps && echo fail || echo ok
262 test=`expr $test + 1`
263
264 ######################################################################
265
266 echo -n "test $test (-cy insufficient) "
267 $hashcash -cqy -b+0 -r '*@foo.com' < stamps && echo fail || echo ok
268 test=`expr $test + 1`
269
270 ######################################################################
271
272 echo -n "test $test (-cy -b10 no match) "
273 $hashcash -cqy -b10 -r '*@taz.com' < stamps && echo fail || echo ok
274 test=`expr $test + 1`
275
276 ######################################################################
277
278 echo -n "test $test (-cy -b5 expired) "
279 $hashcash -cqy -b5 -r '[email protected]' < stamps && echo fail || echo ok
280 test=`expr $test + 1`
281
282 ######################################################################
283
284 echo -n "test $test (-cy -b5 future) "
285 $hashcash -cqy -b5 -r '[email protected]' < stamps && echo fail || echo ok
286 test=`expr $test + 1`
287
288
289 ######################################################################
290 # -c with exit codes
291 ######################################################################
292
293 echo -n "test $test (-c -b10 partial) "
294 $hashcash -cq -b10 -r '*@foo.com' < stamps
295 [ $? -eq 2 ] && echo ok || echo fail
296 test=`expr $test + 1`
297
298 ######################################################################
299
300 echo -n "test $test (-cy -b10 success) "
301 $hashcash -cyq -b10 -r '*@foo.com' < stamps
302 [ $? -eq 0 ] && echo ok || echo fail
303 test=`expr $test + 1`
304
305 ######################################################################
306
307 echo -n "test $test (-c -b15 insufficient) "
308 $hashcash -cq -b15 -r '*@foo.com' < stamps
309 [ $? -eq 1 ] && echo ok || echo fail
310 test=`expr $test + 1`
311
312 ######################################################################
313
314 echo -n "test $test (-c -b10 no match) "
315 $hashcash -cq -b10 -r '*@taz.com' < stamps
316 [ $? -eq 1 ] && echo ok || echo fail
317 test=`expr $test + 1`
318
319 ######################################################################
320
321 echo -n "test $test (-c -b5 expired) "
322 $hashcash -cq -b5 -r '[email protected]' < stamps
323 [ $? -eq 1 ] && echo ok || echo fail
324 test=`expr $test + 1`
325
326 ######################################################################
327
328 echo -n "test $test (-c -b5 future) "
329 $hashcash -cq -b5 -r '[email protected]' < stamps
330 [ $? -eq 1 ] && echo ok || echo fail
331 test=`expr $test + 1`
332
333
334 ######################################################################
335 # -cn
336 ######################################################################
337
338 cat > out.$test <<EOF
339 [email protected]
340 EOF
341
342 echo -n "test $test (-cn -b10 one sufficient) "
343 $hashcash -cnq -b10 -r '*@foo.com' < stamps > res.$test
344 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
345 test=`expr $test + 1`
346
347 ######################################################################
348
349 cat > out.$test <<EOF
350 [email protected]
351 [email protected]
352 [email protected]
353 EOF
354
355 echo -n "test $test (-cn -b5 three valid) "
356 $hashcash -cnq -b5 -r '*@foo.com' < stamps > res.$test
357 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
358 test=`expr $test + 1`
359
360 ######################################################################
361
362 cat > out.$test <<EOF
363 [email protected]
364 [email protected]
365 EOF
366
367 echo -n "test $test (-cn -b5 two match) "
368 $hashcash -cnq -b5 -r '*[email protected]' < stamps > res.$test
369 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
370 test=`expr $test + 1`
371
372 ######################################################################
373
374 echo -n "" > out.$test
375
376 echo -n "test $test (-cn none sufficient) "
377 $hashcash -cnqb+0 -r '*[email protected]' < stamps > res.$test
378 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
379 test=`expr $test + 1`
380
381 ######################################################################
382
383 cat > out.$test <<EOF
384 [email protected]
385 EOF
386
387 echo -n "test $test (-cn -r -o -r one sufficient) "
388 $hashcash -cnqb10 -r '*[email protected]' < stamps > res.$test
389 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
390 test=`expr $test + 1`
391
392
393 ######################################################################
394 # -cw
395 ######################################################################
396
397 cat > out.$test <<EOF
398 5
399 12
400 6
401 EOF
402
403 echo -n "test $test (-cwb5 three valid) "
404 $hashcash -cwqb5 < stamps > res.$test
405 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
406 test=`expr $test + 1`
407
408 ######################################################################
409
410 cat > out.$test <<EOF
411 5
412 12
413 EOF
414
415 echo -n "test $test (-cwb5 -r two valid match) "
416 $hashcash -cwqb5 -r '*[email protected]' < stamps > res.$test
417 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
418 test=`expr $test + 1`
419
420 ######################################################################
421 # -cl
422 ######################################################################
423
424 cat > out.$test <<EOF
425 2419200
426 2419200
427 2592000
428 EOF
429
430 echo -n "test $test (-cl -b5 three sufficient) "
431 $hashcash -clq -b5 < stamps > res.$test
432 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
433 test=`expr $test + 1`
434
435 ######################################################################
436
437 echo -n "test $test (-c -b10 -r [email protected] -o -b5 -r *@foo.com partial) "
438 $hashcash -cqb10 -r '[email protected]' -o -b5 -r '*[email protected]' < stamps
439 [ $? -eq 2 ] && echo ok || echo fail
440 test=`expr $test + 1`
441
442 ######################################################################
443
444 echo -n "test $test (-c -b10 -r blah -o -b6 -r blah -r *[email protected] partial) "
445 $hashcash -cqb10 -r '[email protected]' -o -b6 -r '*[email protected]' \
446 -r '*[email protected]' < stamps
447 [ $? -eq 2 ] && echo ok || echo fail
448 test=`expr $test + 1`
449
450 ######################################################################
451
452 cat > out.$test <<EOF
453 2419200
454 2419200
455 2592000
456 EOF
457
458 echo -n "test $test (-cl -b5 three sufficient) "
459 $hashcash -clq -b5 < stamps > res.$test
460 diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail
461 test=`expr $test + 1`
462