torrents.test.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. const { eq, ok } = require('../../helpers/assert');
  2. const { makeNetwork, makePeer } = require('../../helpers/setup');
  3. const BLOB = '[t](&torrent00000000000000000000000000000000000000000000.sha256)';
  4. describe('torrents: create + list + opinion', (t) => {
  5. t('A creates torrent', async () => {
  6. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  7. const r = await A.use('torrents').createTorrent(BLOB, ['linux'], 'Iso', 'd', 1000000, null);
  8. ok(r);
  9. const list = await A.use('torrents').listAll('all');
  10. ok(list.length >= 1);
  11. });
  12. t('A casts opinion on torrent', async () => {
  13. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  14. const r = await A.use('torrents').createTorrent(BLOB, [], 'T', '', 1, null);
  15. await A.use('torrents').createOpinion(r.key, 'interesting');
  16. });
  17. t('A deletes own torrent', async () => {
  18. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  19. const r = await A.use('torrents').createTorrent(BLOB, [], 'T', '', 1, null);
  20. await A.use('torrents').deleteTorrentById(r.key);
  21. const list = await A.use('torrents').listAll('all');
  22. const found = list.find(x => x.title === 'T');
  23. ok(!found);
  24. });
  25. });