#!/bin/sh hashcash="../hashcash -u -t 040404" sha1="../sha1" mkdir -p test cd test #v=1 test=1 ###################################################################### echo -n "test $test (-mb8) " $hashcash -mqb8 foo@bar.com > stamp.$test echo -n `cat stamp.$test` | $sha1 | sed 's/^\(..\).*/\1/' > res.$test echo 00 > out.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-mb12) " $hashcash -mqb12 foo@bar.com > stamp.$test echo -n `cat stamp.$test` | $sha1 | sed 's/^\(...\).*/\1/' > res.$test echo 000 > out.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-mb8 -mb12) " $hashcash -mqb8 foo@bar.com -b12 taz@bar.com > stamp.$test echo -n `head -1 stamp.$test` | $sha1 | sed 's/^\(..\).*/\1/' > res1.$test echo 00 > out1.$test echo -n `tail -1 stamp.$test` | $sha1 | sed 's/^\(...\).*/\1/' > res2.$test echo 000 > out2.$test diff -q res1.$test out1.$test 1> /dev/null 2>&1 && \ diff -q res2.$test out2.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-b10 partial) " $hashcash -q -b10 < stamps [ $? -eq 2 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-b15 insufficient) " $hashcash -q -b15 < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-r partial) " $hashcash -q -r '*@foo.com' < stamps [ $? -eq 2 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-r no match) " $hashcash -q -r '*@taz.com' < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-d not spent) " cat > db.$test < stamp.$test < db.$test < stamp.$test < stamps < out.$test < res.$test" $hashcash -wq < stamps > res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-wb10 one sufficient) " cat > stamp.$test < out.$test < res.$test" $hashcash -wqb10 < stamp.$test > res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-wn) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-n) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-nb10) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-nr three match) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-l) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-nl) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-wl) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-nwl) " cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### # -c with -y ###################################################################### echo -n "test $test (-cy -b10 match) " $hashcash -cqy -b10 -r '*@foo.com' < stamps && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy -b15 insufficient) " $hashcash -cqy -b15 -r '*@foo.com' < stamps && echo fail || echo ok test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy insufficient) " $hashcash -cqy -b+0 -r '*@foo.com' < stamps && echo fail || echo ok test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy -b10 no match) " $hashcash -cqy -b10 -r '*@taz.com' < stamps && echo fail || echo ok test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy -b5 expired) " $hashcash -cqy -b5 -r 'fax@foo.com' < stamps && echo fail || echo ok test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy -b5 future) " $hashcash -cqy -b5 -r 'space@foo.com' < stamps && echo fail || echo ok test=`expr $test + 1` ###################################################################### # -c with exit codes ###################################################################### echo -n "test $test (-c -b10 partial) " $hashcash -cq -b10 -r '*@foo.com' < stamps [ $? -eq 2 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-cy -b10 success) " $hashcash -cyq -b10 -r '*@foo.com' < stamps [ $? -eq 0 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b15 insufficient) " $hashcash -cq -b15 -r '*@foo.com' < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b10 no match) " $hashcash -cq -b10 -r '*@taz.com' < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b5 expired) " $hashcash -cq -b5 -r 'fax@foo.com' < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b5 future) " $hashcash -cq -b5 -r 'space@foo.com' < stamps [ $? -eq 1 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### # -cn ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "" > out.$test echo -n "test $test (-cn none sufficient) " $hashcash -cnqb+0 -r '*+bar@foo.com' < stamps > res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### # -cw ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### # -cl ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b10 -r adam+bar@foo.com -o -b5 -r *@foo.com partial) " $hashcash -cqb10 -r 'adam+bar@foo.com' -o -b5 -r '*+bar@foo.com' < stamps [ $? -eq 2 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### echo -n "test $test (-c -b10 -r blah -o -b6 -r blah -r *+xyz@foo.com partial) " $hashcash -cqb10 -r 'adam+bar@foo.com' -o -b6 -r '*+bar@foo.com' \ -r '*+xyz@foo.com' < stamps [ $? -eq 2 ] && echo ok || echo fail test=`expr $test + 1` ###################################################################### cat > out.$test < res.$test diff -q res.$test out.$test 1> /dev/null 2>&1 && echo ok || echo fail test=`expr $test + 1`