Commit 609307921c4c0a7292513248cc13f16b199ec5f0
added i64 test
wanderer committed on 3/30/2018, 6:04:23 PMParent: 0f31d31650ad897c852214495d044937472b54b9
Files changed
index.js | changed |
tests/index.js | changed |
tests/wasm/i64.wasm | added |
tests/wast/i64.wast | added |
tests/wast/private_caller.wasm | deleted |
index.js | ||
---|---|---|
@@ -250,21 +250,25 @@ | ||
250 | 250 | } |
251 | 251 | this.instance.exports.setter_globals(...refs) |
252 | 252 | } |
253 | 253 | |
254 | - // call entrypoint function | |
255 | - let wasmFunc | |
256 | - if (funcRef.identifier[0]) { | |
257 | - wasmFunc = this.instance.exports.table.get(funcRef.identifier[1]) | |
258 | - } else { | |
259 | - wasmFunc = this.instance.exports[funcRef.identifier[1]] | |
254 | + try { | |
255 | + // call entrypoint function | |
256 | + let wasmFunc | |
257 | + if (funcRef.identifier[0]) { | |
258 | + wasmFunc = this.instance.exports.table.get(funcRef.identifier[1]) | |
259 | + } else { | |
260 | + wasmFunc = this.instance.exports[funcRef.identifier[1]] | |
261 | + } | |
262 | + | |
263 | + const wrapper = generateWrapper(funcRef) | |
264 | + wrapper.exports.table.set(0, wasmFunc) | |
265 | + wrapper.exports.invoke(...args) | |
266 | + await this.onDone() | |
267 | + } catch (e) { | |
268 | + console.log(e) | |
260 | 269 | } |
261 | 270 | |
262 | - const wrapper = generateWrapper(funcRef) | |
263 | - wrapper.exports.table.set(0, wasmFunc) | |
264 | - wrapper.exports.invoke(...args) | |
265 | - await this.onDone() | |
266 | - | |
267 | 271 | // store globals |
268 | 272 | numOfGlobals = this.json.persist.length |
269 | 273 | if (numOfGlobals) { |
270 | 274 | const storage = [] |
tests/index.js | ||
---|---|---|
@@ -36,47 +36,27 @@ | ||
36 | 36 | }) |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | -tape.skip('bwasic', async t => { | |
41 | - // t.plan(1) | |
40 | +tape('i64', async t => { | |
41 | + t.plan(1) | |
42 | 42 | tester = t |
43 | - | |
44 | - const typeInfo = { | |
45 | - 'types': [{ | |
46 | - 'form': 'func', | |
47 | - 'params': [ | |
48 | - 'i64', | |
49 | - 'data' | |
50 | - ] | |
51 | - }], | |
52 | - 'typeMap': [{ | |
53 | - 'func': 46, | |
54 | - 'type': 0 | |
55 | - }] | |
56 | - } | |
57 | - | |
58 | 43 | const tree = new RadixTree({db}) |
44 | + let wasm = fs.readFileSync(WASM_PATH + '/i64.wasm') | |
59 | 45 | |
60 | - let wasm = fs.readFileSync('./test.wasm') | |
61 | - wasm = annotations.encodeAndInject(typeInfo, wasm) | |
62 | - | |
63 | 46 | const hypervisor = new Hypervisor(tree) |
64 | 47 | hypervisor.registerContainer(TestWasmContainer) |
65 | 48 | |
66 | 49 | const {module} = await hypervisor.createActor(TestWasmContainer.typeId, wasm) |
67 | - const funcRef = module.getFuncRef('#main') | |
50 | + const funcRef = module.getFuncRef('main') | |
68 | 51 | funcRef.gas = 322000 |
69 | 52 | |
70 | 53 | const message = new Message({ |
71 | 54 | funcRef |
72 | 55 | }).on('execution:error', e => { |
73 | 56 | console.log(e) |
74 | 57 | }) |
75 | 58 | hypervisor.send(message) |
76 | - // const stateRoot = await hypervisor.createStateRoot() | |
77 | - // t.deepEquals(stateRoot, expectedState, 'expected root!') | |
78 | - t.end() | |
79 | 59 | }) |
80 | 60 | |
81 | 61 | tape('basic', async t => { |
82 | 62 | t.plan(1) |
tests/wasm/i64.wasm | ||
---|---|---|
@@ -1,0 +1,2 @@ | ||
1 | + asm ` ` `` `~ Tfuncinternalize testcheck moduleself moduleexport memoryexternalize p $memory table main callback | |
2 | +# A A A BA A � A callback |
tests/wast/i64.wast | ||
---|---|---|
@@ -1,0 +1,26 @@ | ||
1 | +(module | |
2 | + (import "func" "internalize" (func $func.internalize (param i32 i32))) | |
3 | + (import "test" "check" (func $check (param i32 i32))) | |
4 | + (import "module" "self" (func $self (result i32))) | |
5 | + (import "module" "export" (func $exports (param i32 i32) (result i32))) | |
6 | + (import "memory" "externalize" (func $mem.externalize (param i32 i32) (result i32))) | |
7 | + (memory (export "memory") 1) | |
8 | + (data (i32.const 0) "callback") | |
9 | + (table (export "table") 1 1 anyfunc) | |
10 | + (func $main | |
11 | + (call $func.internalize | |
12 | + (i32.const 0) | |
13 | + (call $exports | |
14 | + (call $self) | |
15 | + (call $mem.externalize (i32.const 0) (i32.const 8)) | |
16 | + ) | |
17 | + ) | |
18 | + (call_indirect (param i64) (i64.const 8) (i32.const 0)) | |
19 | + ) | |
20 | + (func $callback (param i64) | |
21 | + (i32.const 8) | |
22 | + (i32.wrap/i64 (get_local 0)) | |
23 | + call $check | |
24 | + ) | |
25 | + (export "main" (func $main)) | |
26 | + (export "callback" (func $callback))) |
Built with git-ssb-web