git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit bb6ef21471bd09c766ab63064037d371607de931

add test for empty module

Norton Wang committed on 3/5/2018, 4:04:46 AM
Parent: 49051b3e16dc9927b3bbcfe2f7a8af88ccc8a232

Files changed

tests/wasm/empty.wasmadded
tests/wasmContainer.jschanged
tests/wasm/empty.wasmView
@@ -1,0 +1,1 @@
1+asm����p������������memory
tests/wasmContainer.jsView
@@ -62,8 +62,37 @@
6262 const stateRoot = await hypervisor.createStateRoot()
6363 // t.deepEquals(stateRoot, expectedState, 'expected root!')
6464 })
6565
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+
6695 tape('two communicating actors', async t => {
6796 t.plan(1)
6897 tester = t
6998 const expectedState = {

Built with git-ssb-web