interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / salvage / tests / journey.om

200 lines · 5502 bytes Raw Blame History
1note Compose all forge units with server main renamed, then this unit. argv[1] fresh private directory.
2note Session identity fixture calls the real write gate; HTTP sign-in is separately exercised with throwaway keys.
3text qva "did:key:builder-a"
4text qvb "did:key:builder-b"
5text qvcsrf "11111111111111111111111111111111"
6text qvsrc "csrf=11111111111111111111111111111111&action=source&consent=yes&title=Broken+hello&origin=https%3A%2F%2Fexample.org%2Fidea&license=MIT&description=%3Cscript%3Ealert%281%29%3C%2Fscript%3E&source=unfinished&credit=Original+Builder&language=text"
7text qvpart "csrf=11111111111111111111111111111111&action=derive&consent=yes&title=Useful+hello&description=Repaired+example&source=om2%0D%0Atext+msg+%22hello%5Cn%22%0D%0Afn+main+to+int%0D%0Ar+%3D+write+1+msg+0+len+msg%0D%0Aret+0%0D%0Aend%0D%0A&input=&expected=hello%0D%0A"
8text qvverify "csrf=11111111111111111111111111111111&action=verify"
9text qvpub "csrf=11111111111111111111111111111111&action=publish"
10text qvwith "csrf=11111111111111111111111111111111&action=withdraw"
11text qvbad "csrf=bad&action=source"
12text qvdup "csrf=11111111111111111111111111111111&action=source&action=derive"
13text qvesc "<script>"
14text qvexp "hello\n"
15text qvpass "SALVAGE_JOURNEY PASS\n"
16text qvpct "csrf=11111111111111111111111111111111&action=source&source=a%ZZworld"
17text qvpct2 "csrf=11111111111111111111111111111111&action=source&source=a%&title=b"
18text qvpct3 "csrf=11111111111111111111111111111111&action=source&source=a%"
19text qvbadp "SALVAGE_JOURNEY FAIL assertion "
20global qvcnt ulong 1
21fn qvassert yes bool to void
22b = new uchar 3 0
23put qvcnt 0 add get qvcnt 0 1
24if not yes
25n = get qvcnt 0
26put b 0 uchar add div n 10 48
27put b 1 uchar add rem n 10 48
28put b 2 10
29r = write 2 qvbadp 0 len qvbadp
30r = write 2 b 0 3
31exit 1
32end
33end
34fn qvuser name view uchar * to void
35sokclr
36sokt name
37who = sointern
38put gscur 0 who
39put gsok 0 1
40put fcsrfl 0 32
41for i ulong 32
42put fcsrf i get qvcsrf i
43end
44end
45fn qvbody data view uchar * to void
46fresetr
47put fmeth 0 3
48put fbodyl 0 len data
49put fbasel 0 1
50put fbase 0 47
51for i ulong len data bound 65536
52put fbody i get data i
53end
54end
55fn qvfind s view uchar * to bool
56n = get fobl 0
57if lt n len s
58ret false
59end
60for i ulong add sub n len s 1 bound 65536
61same = true
62for j ulong len s bound 256
63if ne get fob add i j get s j
64same = false
65end
66end
67if same
68ret true
69end
70end
71ret false
72end
73text qvjunk "stale"
74note qvnext: <root>job.next, the name sljobstart writes before its rename. qvnew true creates it
75note (a server that stopped between its write and its rename); false reports whether it exists.
76fn qvnext qvnew bool to bool
77t = new uchar 1100 0
78b = new uchar 16 0
79slpath tlempty tljob
80n = slpget t
81for i ulong len tlnext
82put t add n i get tlnext i
83end
84m = add n len tlnext
85if qvnew
86ret slwrite view part t 0 m qvjunk 557249
87end
88ret ne slread view part t 0 m b -2
89end
90fn main to int
91p = new uchar 512 0
92srcid = new uchar 64 0
93partid = new uchar 64 0
94b = new uchar 4096 0
95for i ulong 8
96qvassert eq slpubgate ne and i 4 0 ne and i 2 0 ne and i 1 0 eq i 7
97end
98n = argread 1 p 0 512
99qvassert gt n 0
100qvassert slroot view part p 0 ulong n
101qvassert slinit
102put glboot 0 1
103soreset
104qvbody qvsrc
105qvassert eq slpost tlempty 303
106qvassert eq get glidxn 0 0
107qvuser qva
108qvbody qvbad
109qvassert eq slpost tlempty 403
110qvbody qvpct
111qvassert eq slpost tlempty 400
112qvbody qvpct2
113qvassert eq slpost tlempty 400
114qvbody qvpct3
115qvassert eq slpost tlempty 400
116qvbody qvsrc
117qvassert eq slpost tlempty 303
118qvassert gt get gsrlc get gscur 0 0
119qvassert eq get glidxn 0 1
120for i ulong 64
121put srcid i get glrid i
122end
123put gscur 0 0
124qvassert slpublic srcid
125fresetr
126qvassert eq slitem srcid 200
127qvassert qvfind qvesc
128qvuser qva
129qvbody qvdup
130qvassert eq slpost tlempty 400
131qvassert eq get glidxn 0 1
132qvuser qvb
133qvbody qvpart
134qvassert eq slpost srcid 303
135qvassert eq get glidxn 0 2
136for i ulong 64
137put partid i get glrid i
138end
139qvassert slload partid
140qvassert slfeq 8 qvexp
141qvassert slown
142put gscur 0 0
143qvassert not slaccess partid
144qvuser qva
145qvassert not slaccess partid
146qvuser qvb
147qvassert slaccess partid
148qvbody qvpub
149qvassert eq slpost partid 409
150note a job.next left by a server that stopped before its rename does not hold the queue
151qvassert qvnext true
152qvbody qvverify
153qvassert eq slpost partid 303
154note the server only queued the job: no receipt exists until the collector has run
155qvassert sljobis partid
156qvassert not sljobis srcid
157qvassert ne slreceiptget partid 1
158note a queued job refuses the next one
159qvassert not sljobstart partid
160note the refused job leaves no job.next behind
161qvassert not qvnext false
162note one collector pass (the collector program calls the same function) takes the job
163qvassert eq slcollect 1
164qvassert not sljobis partid
165qvassert eq slcollect 0
166qvassert eq slreceiptget partid 1
167qvbody qvpub
168qvassert eq slpost partid 303
169put gscur 0 0
170qvassert slpublic partid
171fresetr
172qvassert eq slbundle partid 200
173qvassert gt get fobl 0 4096
174qvuser qva
175qvbody qvwith
176qvassert eq slpost partid 403
177qvassert eq slgetstate partid 1
178qvbody qvwith
179qvassert eq slpost srcid 303
180put gscur 0 0
181qvassert not slpublic srcid
182qvassert not slpublic partid
183qvassert not slaccess partid
184qvuser qva
185qvbody qvsrc
186qvassert eq slpost tlempty 303
187qvassert eq slgetstate srcid 2
188put gscur 0 0
189qvassert not slpublic partid
190qvuser qvb
191qvbody qvpub
192qvassert eq slpost partid 409
193qvuser qvb
194put gsrlm get gscur 0 div get gsnow 0 60
195put gsrlc get gscur 0 30
196qvbody qvpub
197qvassert eq slpost partid 429
198r = write 1 qvpass 0 len qvpass
199ret 0
200end