git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 81bc698eafe0e2013602fe8f6e9aae6fe7b0ee7b

Files: 81bc698eafe0e2013602fe8f6e9aae6fe7b0ee7b / tests / interface / basic_gas_ops.wast

912 bytesRaw
1;; starts with 1000 gas
2(module
3 (import $addGas "ethereum" "addGas" (param i32))
4 (import $gasUsed "ethereum" "gasUsed" (result i64))
5 (import $gasLeft "ethereum" "gasLeft" (result i64))
6
7 (export "test" 0)
8 (func
9 ;; test adding gas
10 (block
11 (call_import $addGas (i32.const 1))
12 (if (i64.eq (call_import $gasUsed) (i64.const 1))
13 (return)
14 )
15 (unreachable)
16 )
17 (block
18 (call_import $addGas (i32.const 1))
19 (if (i64.eq (call_import $gasUsed) (i64.const 2))
20 (return)
21 )
22 (unreachable)
23 )
24 ;; should disregard negative values
25 (block
26 (call_import $addGas (i32.const -1))
27 (if (i64.eq (call_import $gasUsed) (i64.const 2))
28 (return)
29 )
30 (unreachable)
31 )
32 ;; gas left
33 (block
34 (if (i64.eq (call_import $gasLeft) (i64.const 998))
35 (return)
36 )
37 (unreachable)
38 )
39 )
40)
41

Built with git-ssb-web