(t *testing.T)
| 155 | } |
| 156 | |
| 157 | func TestOptions(t *testing.T) { |
| 158 | const startLimit int64 = 1000 |
| 159 | |
| 160 | cases := []struct { |
| 161 | name string |
| 162 | src string |
| 163 | items []string // represents the objects on top of the stack as the program progresses |
| 164 | cost int64 |
| 165 | }{ |
| 166 | { |
| 167 | name: "log ops", |
| 168 | src: "10 log 0 peeklog log 'blockchainid' 8 nonce finalize", |
| 169 | items: []string{ |
| 170 | "{'Z', 10}", |
| 171 | "{'Z', 0}", |
| 172 | "{'T', {'L', x'0000000000000000000000000000000000000000000000000000000000000000', 10}}", |
| 173 | "{'S', 'blockchainid'}", |
| 174 | "{'Z', 8}", |
| 175 | "{'V', 0, x'0000000000000000000000000000000000000000000000000000000000000000', x'51a2a5efebb78d8907c97c07f807ef8b72a0482a959224cfd1555103c6195cd6'}", |
| 176 | }, |
| 177 | cost: 178, |
| 178 | }, |
| 179 | { |
| 180 | name: "basic math", |
| 181 | src: "10 2 add 3 div 3 mod 2 gt not verify 'id' 10 nonce finalize", |
| 182 | items: []string{ |
| 183 | "{'Z', 10}", |
| 184 | "{'Z', 2}", |
| 185 | "{'Z', 12}", |
| 186 | "{'Z', 3}", |
| 187 | "{'Z', 4}", |
| 188 | "{'Z', 3}", |
| 189 | "{'Z', 1}", |
| 190 | "{'Z', 2}", |
| 191 | "{'Z', 0}", |
| 192 | "{'Z', 1}", |
| 193 | "{'S', 'id'}", |
| 194 | "{'Z', 10}", |
| 195 | "{'V', 0, x'0000000000000000000000000000000000000000000000000000000000000000', x'87f629d8630208e6756a515c60335d75da8dce70eadcccd58a937a70b1e7eaa3'}", |
| 196 | }, |
| 197 | cost: 162, |
| 198 | }, |
| 199 | } |
| 200 | for _, c := range cases { |
| 201 | t.Run(c.name, func(t *testing.T) { |
| 202 | prog, err := asm.Assemble(c.src) |
| 203 | if err != nil { |
| 204 | t.Fatal(err) |
| 205 | } |
| 206 | |
| 207 | var runlimit int64 |
| 208 | i := 0 |
| 209 | |
| 210 | var b bytes.Buffer |
| 211 | id, err := txvm.Validate(prog, 3, startLimit, |
| 212 | txvm.BeforeStep(func(v *txvm.VM) { |
| 213 | compareItems(t, v.StackItem(v.StackLen()-1).String(), c.items[i]) |
| 214 | i++ |
nothing calls this directly
no test coverage detected