Files: 9aeb50b928d404dec97a93aa0c1143d8e3ddd114 / tests / index.js
654 bytesRaw
1 | const tape = require('tape') |
2 | const IPFS = require('ipfs') |
3 | const RadixTree = require('../') |
4 | |
5 | // start ipfs |
6 | const node = new IPFS({ |
7 | start: false |
8 | }) |
9 | |
10 | node.on('ready', () => { |
11 | tape('set', async t => { |
12 | const tree = new RadixTree({ |
13 | dag: node.dag |
14 | }) |
15 | try { |
16 | await tree.set('test', 'cat') |
17 | let val = await tree.get('test') |
18 | t.equals(val, 'cat') |
19 | await tree.set('te', 'blop') |
20 | // console.log(JSON.stringify(tree.root, null, 2)) |
21 | val = await tree.get('test') |
22 | t.equals(val, 'cat') |
23 | |
24 | val = await tree.get('te') |
25 | t.equals(val, 'blop') |
26 | } catch (e) { |
27 | console.log(e) |
28 | } |
29 | t.end() |
30 | }) |
31 | }) |
32 |
Built with git-ssb-web