1 ! Copyright (C) 2022 Zoltán Kéri.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar hashcash hashcash.private kernel
4 literals namespaces sequences splitting tools.test ;
7 ! We do not want to generate it multiple times. It would be too slow.
8 CONSTANT: generated-mint $[ "foo@bar.com" mint ]
10 { t } [ generated-mint dup ":" split third valid-date? swap drop ] unit-test
14 generated-mint valid-stamp?
20 generated-mint valid-stamp?
24 { t } [ generated-mint valid-stamp? ] unit-test
27 <hashcash> "foo@bar.com" >>resource 16 >>bits
32 [ 9999 expiry-days set
33 "1:20:220403:foo@bar.com::fAY*-p!s:23472" valid-stamp?
39 now-gmt-yymmdd valid-date?
45 now-gmt-yymmdd valid-date?
49 { t } [ now-gmt-yymmdd valid-date? ] unit-test
51 { 30 } [ "220131" "220101" yymmdd-gmt-diff ] unit-test
52 { -30 } [ "220101" "220131" yymmdd-gmt-diff ] unit-test
54 { t } [ now-gmt 1 days time- timestamp>yymmdd on-or-before-today? nip ] unit-test
55 { t } [ now-gmt timestamp>yymmdd on-or-before-today? nip ] unit-test
56 { f } [ now-gmt 1 days time+ timestamp>yymmdd on-or-before-today? nip ] unit-test