5
5
const chai = require ( 'chai' )
6
6
const expect = chai . expect
7
7
const { each } = require ( 'async' )
8
+ const CID = require ( 'cids' )
9
+
8
10
const Pulsarcast = require ( '../../src' )
9
11
const TopicNode = require ( '../../src/dag/topic-node' )
10
12
const EventNode = require ( '../../src/dag/event-node' )
@@ -16,9 +18,7 @@ describe('multiple nodes', function () {
16
18
// Topics
17
19
let topic
18
20
let topicCID
19
- let parentTopic
20
21
let parentTopicCID
21
- let subTopic
22
22
let subTopicCID
23
23
24
24
// Parameters
@@ -49,13 +49,14 @@ describe('multiple nodes', function () {
49
49
nodes [ publisher + 1 ] . createTopic ( 'test-parent' , ( err , savedCID , topicNode ) => {
50
50
expect ( err ) . to . not . exist
51
51
expect ( topicNode ) . to . be . an . instanceof ( TopicNode )
52
+ expect ( topicNode . subTopics . meta ) . to . be . an . instanceof ( CID )
52
53
topicNode . getCID ( ( err , cid ) => {
53
54
expect ( err ) . to . not . exist
54
55
const topicB58Str = cid . toBaseEncodedString ( )
55
56
expect ( cid . equals ( savedCID ) ) . to . be . true
56
- expect ( nodes [ publisher + 1 ] . subscriptions . size ) . to . equal ( 1 )
57
+ // Topic and meta topic
58
+ expect ( nodes [ publisher + 1 ] . subscriptions . size ) . to . equal ( 2 )
57
59
expect ( nodes [ publisher + 1 ] . subscriptions . has ( topicB58Str ) ) . to . be . true
58
- parentTopic = topicNode
59
60
parentTopicCID = cid
60
61
done ( )
61
62
} )
@@ -66,13 +67,13 @@ describe('multiple nodes', function () {
66
67
nodes [ publisher + 1 ] . createTopic ( 'test-subtopic' , ( err , savedCID , topicNode ) => {
67
68
expect ( err ) . to . not . exist
68
69
expect ( topicNode ) . to . be . an . instanceof ( TopicNode )
70
+ expect ( topicNode . subTopics . meta ) . to . be . an . instanceof ( CID )
69
71
topicNode . getCID ( ( err , cid ) => {
70
72
expect ( err ) . to . not . exist
71
73
const topicB58Str = cid . toBaseEncodedString ( )
72
74
expect ( cid . equals ( savedCID ) ) . to . be . true
73
- expect ( nodes [ publisher + 1 ] . subscriptions . size ) . to . equal ( 2 )
75
+ expect ( nodes [ publisher + 1 ] . subscriptions . size ) . to . equal ( 4 )
74
76
expect ( nodes [ publisher + 1 ] . subscriptions . has ( topicB58Str ) ) . to . be . true
75
- subTopic = topicNode
76
77
subTopicCID = cid
77
78
done ( )
78
79
} )
@@ -89,13 +90,14 @@ describe('multiple nodes', function () {
89
90
} , ( err , savedCID , topicNode ) => {
90
91
expect ( err ) . to . not . exist
91
92
expect ( topicNode ) . to . be . an . instanceof ( TopicNode )
92
- topicNode . parent . equals ( parentTopic )
93
- topicNode . subTopics [ 'test-subtopic' ] . equals ( subTopic )
93
+ expect ( topicNode . subTopics . meta ) . to . be . an . instanceof ( CID )
94
+ expect ( topicNode . parent . equals ( parentTopicCID ) ) . to . be . true
95
+ expect ( topicNode . subTopics [ 'test-subtopic' ] . equals ( subTopicCID ) ) . to . be . true
94
96
topicNode . getCID ( ( err , cid ) => {
95
97
expect ( err ) . to . not . exist
96
98
const topicB58Str = cid . toBaseEncodedString ( )
97
99
expect ( cid . equals ( savedCID ) ) . to . be . true
98
- expect ( nodes [ publisher ] . subscriptions . size ) . to . equal ( 1 )
100
+ expect ( nodes [ publisher ] . subscriptions . size ) . to . equal ( 2 )
99
101
expect ( nodes [ publisher ] . subscriptions . has ( topicB58Str ) ) . to . be . true
100
102
topic = topicNode
101
103
topicCID = cid
0 commit comments