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