tests/wasmContainer.jsView |
---|
62 | 62 | const stateRoot = await hypervisor.createStateRoot() |
63 | 63 | |
64 | 64 | }) |
65 | 65 | |
| 66 | +tape('empty', async t => { |
| 67 | + t.plan(1) |
| 68 | + tester = t |
| 69 | + const expectedState = { |
| 70 | + '/': Buffer.from('a2440f97e233b183f5e66fb6d60765311be7a2b7', 'hex') |
| 71 | + } |
| 72 | + |
| 73 | + const tree = new RadixTree({ |
| 74 | + db |
| 75 | + }) |
| 76 | + |
| 77 | + const wasm = fs.readFileSync(WASM_PATH + '/empty.wasm') |
| 78 | + |
| 79 | + const hypervisor = new Hypervisor(tree) |
| 80 | + hypervisor.registerContainer(TestWasmContainer) |
| 81 | + |
| 82 | + const {module} = await hypervisor.createActor(TestWasmContainer.typeId, wasm) |
| 83 | + const funcRef = module.getFuncRef('receive') |
| 84 | + funcRef.gas = 300 |
| 85 | + |
| 86 | + const message = new Message({ |
| 87 | + funcRef, |
| 88 | + funcArguments: [5] |
| 89 | + }) |
| 90 | + hypervisor.send(message) |
| 91 | + const stateRoot = await hypervisor.createStateRoot() |
| 92 | + t.deepEquals(stateRoot, expectedState, 'expected root!') |
| 93 | +}) |
| 94 | + |
66 | 95 | tape('two communicating actors', async t => { |
67 | 96 | t.plan(1) |
68 | 97 | tester = t |
69 | 98 | const expectedState = { |