git ssb

0+

wanderer🌟 / js-primea-objects



Tree: c1f75caa1f59885fb55c6c10451c5b0dbafab401

Files: c1f75caa1f59885fb55c6c10451c5b0dbafab401 / tests / index.js

961 bytesRaw
1const tape = require('tape')
2const cbor = require('borc')
3const objects = require('../')
4
5tape('system objects', t => {
6 const msg = new objects.Message({
7 ticks: 100
8 })
9
10 t.equals(msg.ticks, 100)
11 msg.ticks = 10
12 t.equals(msg.ticks, 10)
13
14 const id = new objects.ID(Buffer.from([0x1]))
15 const enid = cbor.encode(id)
16 const rid = objects.decoder.decodeFirst(enid)
17 t.equals(rid.id.toString('hex'), '01')
18
19 const modRef = new objects.ModuleRef({'name': ['i32']}, id)
20 const enmod = cbor.encode(modRef)
21 const rmodRef = objects.decoder.decodeFirst(enmod)
22 t.deepEquals(modRef, rmodRef)
23
24 const funcRef = rmodRef.getFuncRef('name')
25 const enFuncRef = cbor.encode(funcRef)
26 const rFuncRef = objects.decoder.decodeFirst(enFuncRef)
27 t.deepEquals(funcRef, rFuncRef)
28
29 const link = new cbor.Tagged(42, 'data')
30 const enLink = cbor.encode(link)
31 const rLink = objects.decoder.decodeFirst(enLink)
32 t.deepEquals(rLink, {'/': 'data'})
33
34 t.end()
35})
36

Built with git-ssb-web