-
Notifications
You must be signed in to change notification settings - Fork 70
/
hashcash.t
executable file
·48 lines (34 loc) · 1.03 KB
/
hashcash.t
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
#!/usr/bin/perl
use lib '.'; use lib 't';
use SATest; sa_t_init("hashcash");
# we need DB_File to support the double-spend db.
use constant HAS_DB_FILE => eval { require DB_File; };
use Test; BEGIN { plan tests => HAS_DB_FILE ? 4 : 0 };
exit unless HAS_DB_FILE;
# ---------------------------------------------------------------------------
%patterns = (
q{ HASHCASH_24 }, 'hashcash24',
);
tstprefs ('
hashcash_accept test@example.com test1@example.com test2@example.com
hashcash_doublespend_path log/user_state/hashcash_seen
');
sarun ("-L -t < data/nice/001", \&patterns_run_cb);
ok_all_patterns();
%patterns = (
q{ HASHCASH_20 }, 'hashcash20',
);
sarun ("-L -t < data/nice/001", \&patterns_run_cb);
ok_all_patterns();
%patterns = (
q{ HASHCASH_2SPEND }, '2spend',
);
sarun ("-L -t < data/nice/001", \&patterns_run_cb);
ok_all_patterns();
# try again with a mail with 2 tokens, one unspent.
%patterns = ();
%anti_patterns = (
q{ HASHCASH_2SPEND }, '2spend',
);
sarun ("-L -t < data/nice/016", \&patterns_run_cb);
ok_all_patterns();