git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: d6ecef73fd6edc80197140774535f1adea617314

Files: d6ecef73fd6edc80197140774535f1adea617314 / tests / index.js

1429 bytesRaw
1const tape = require('tape')
2const IPFS = require('ipfs')
3const Hypervisor = require('../')
4const Message = require('primea-message')
5
6const node = new IPFS()
7node.on('error', err => {
8 console.log(err)
9})
10
11node.on('start', () => {
12 tape.only('basic', async t => {
13 const testVM = {
14 run (message) {
15 console.log('made it!!!!')
16 }
17 }
18
19 try {
20 const state = {
21 id: {
22 nonce: new Uint8Array([0]),
23 parent: new Uint8Array()
24 },
25 type: 'test',
26 vm: {
27 ports: {}
28 }
29 }
30
31 const hypervisor = new Hypervisor(node.dag)
32 hypervisor.addVM('test', testVM)
33
34 const message = new Message()
35 await hypervisor.send(state, message)
36
37 await hypervisor.createStateRoot(state, Infinity)
38 console.log(state)
39
40 node.stop(() => {
41 t.end()
42 process.exit()
43 })
44 } catch (e) {
45 console.log(e)
46 }
47 })
48
49 tape('messaging', t => {
50 // const state = {
51 // id: {},
52 // ports: {
53 // first: {
54 // id: {
55 // nonce: 1,
56 // parent: 'hash'
57 // },
58 // code: 'js code',
59 // type: 'test',
60 // ports: {
61
62 // }
63 // }
64 // }
65 // }
66 // const message = new Message({
67 // type: 'create',
68 // path: 'first',
69 // data: jsCode
70 // })
71 // hypervisor.send(port, message)
72
73 })
74})
75

Built with git-ssb-web