git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 337e581214f9ce5a65ecad94f1830a0dc0891124

Test counter contract

enzoh committed on 2/7/2018, 11:03:47 PM
Parent: 192e8e23310b0b99e63703b7d840090c2b55ddfb

Files changed

tests/wasm/counter.wasmadded
tests/wasmContainer.jschanged
tests/wasm/counter.wasmView
@@ -1,0 +1,4 @@
1+asm`pmemory increment
2+ 
3+A( Aj
4+A 
tests/wasmContainer.jsView
@@ -49,4 +49,31 @@
4949
5050 const stateRoot = await hypervisor.createStateRoot()
5151 t.deepEquals(stateRoot, expectedState, 'expected root!')
5252 })
53+
54+// Increment a counter.
55+tape('increment', async t => {
56+
57+ const tree = new RadixTree({
58+ db: db
59+ })
60+
61+ const wasm = fs.readFileSync('./wasm/counter.wasm')
62+
63+ const hypervisor = new Hypervisor(tree)
64+ hypervisor.registerContainer(TestWasmContainer)
65+
66+ const {exports} = await hypervisor.createActor(TestWasmContainer.typeId, wasm)
67+
68+ const message = new Message({
69+ funcRef: exports.increment,
70+ funcArguments: []
71+ })
72+ hypervisor.send(message)
73+
74+ const stateRoot = await hypervisor.createStateRoot()
75+ t.end()
76+
77+ console.log(stateRoot)
78+
79+})

Built with git-ssb-web