Commit 337e581214f9ce5a65ecad94f1830a0dc0891124
Test counter contract
enzoh committed on 2/7/2018, 11:03:47 PMParent: 192e8e23310b0b99e63703b7d840090c2b55ddfb
Files changed
tests/wasm/counter.wasm | added |
tests/wasmContainer.js | changed |
tests/wasmContainer.js | ||
---|---|---|
@@ -49,4 +49,31 @@ | ||
49 | 49 | |
50 | 50 | const stateRoot = await hypervisor.createStateRoot() |
51 | 51 | t.deepEquals(stateRoot, expectedState, 'expected root!') |
52 | 52 | }) |
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