1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import { expect } from 'chai' ;
16+ import { expect , assert } from 'chai' ;
1717import { Listener , TransactionHttp } from '../../src/infrastructure/infrastructure' ;
1818import { MosaicHttp } from '../../src/infrastructure/MosaicHttp' ;
1919import { Account } from '../../src/model/account/Account' ;
@@ -24,12 +24,17 @@ import { MosaicProperties } from '../../src/model/mosaic/MosaicProperties';
2424import { NamespaceId } from '../../src/model/namespace/NamespaceId' ;
2525import { Deadline } from '../../src/model/transaction/Deadline' ;
2626import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction' ;
27+ import { RegisterNamespaceTransaction } from '../../src/model/transaction/RegisterNamespaceTransaction' ;
28+ import { UInt64 } from '../../src/model/UInt64' ;
29+ import { MosaicAliasTransaction } from '../../src/model/transaction/MosaicAliasTransaction' ;
30+ import { AliasActionType } from '../../src/model/namespace/AliasActionType' ;
2731
2832describe ( 'MosaicHttp' , ( ) => {
2933 let mosaicId : MosaicId ;
3034 let mosaicHttp : MosaicHttp ;
3135 let account : Account ;
3236 let config ;
37+ let namespaceId : NamespaceId ;
3338 let transactionHttp : TransactionHttp ;
3439 before ( ( done ) => {
3540 const path = require ( 'path' ) ;
@@ -82,6 +87,74 @@ describe('MosaicHttp', () => {
8287 transactionHttp . announce ( signedTransaction ) ;
8388 } ) ;
8489 } ) ;
90+
91+ describe ( 'Setup test NamespaceId' , ( ) => {
92+ let listener : Listener ;
93+ before ( ( ) => {
94+ listener = new Listener ( config . apiUrl ) ;
95+ return listener . open ( ) ;
96+ } ) ;
97+ after ( ( ) => {
98+ return listener . close ( ) ;
99+ } ) ;
100+ it ( 'Announce RegisterNamespaceTransaction' , ( done ) => {
101+ const namespaceName = 'root-test-namespace-' + Math . floor ( Math . random ( ) * 10000 ) ;
102+ const registerNamespaceTransaction = RegisterNamespaceTransaction . createRootNamespace (
103+ Deadline . create ( ) ,
104+ namespaceName ,
105+ UInt64 . fromUint ( 1000 ) ,
106+ NetworkType . MIJIN_TEST ,
107+ ) ;
108+ namespaceId = new NamespaceId ( namespaceName ) ;
109+ const signedTransaction = registerNamespaceTransaction . signWith ( account ) ;
110+ listener . confirmed ( account . address ) . subscribe ( ( transaction ) => {
111+ done ( ) ;
112+ } ) ;
113+ listener . status ( account . address ) . subscribe ( ( error ) => {
114+ console . log ( 'Error:' , error ) ;
115+ assert ( false ) ;
116+ done ( ) ;
117+ } ) ;
118+ transactionHttp . announce ( signedTransaction ) ;
119+ } ) ;
120+ } ) ;
121+ describe ( 'Setup test MosaicAlias' , ( ) => {
122+ let listener : Listener ;
123+ before ( ( ) => {
124+ listener = new Listener ( config . apiUrl ) ;
125+ return listener . open ( ) ;
126+ } ) ;
127+ after ( ( ) => {
128+ return listener . close ( ) ;
129+ } ) ;
130+
131+ it ( 'Announce MosaicAliasTransaction' , ( done ) => {
132+ const mosaicAliasTransaction = MosaicAliasTransaction . create (
133+ Deadline . create ( ) ,
134+ AliasActionType . Link ,
135+ namespaceId ,
136+ mosaicId ,
137+ NetworkType . MIJIN_TEST ,
138+ ) ;
139+ const signedTransaction = mosaicAliasTransaction . signWith ( account ) ;
140+
141+ listener . confirmed ( account . address ) . subscribe ( ( transaction ) => {
142+ done ( ) ;
143+ } ) ;
144+ listener . status ( account . address ) . subscribe ( ( error ) => {
145+ console . log ( 'Error:' , error ) ;
146+ assert ( false ) ;
147+ done ( ) ;
148+ } ) ;
149+ transactionHttp . announce ( signedTransaction ) ;
150+ } ) ;
151+ } ) ;
152+
153+ /**
154+ * =========================
155+ * Test
156+ * =========================
157+ */
85158 describe ( 'getMosaic' , ( ) => {
86159 it ( 'should return mosaic given mosaicId' , ( done ) => {
87160 mosaicHttp . getMosaic ( mosaicId )
@@ -123,4 +196,50 @@ describe('MosaicHttp', () => {
123196 } ) ;
124197 } ) ;
125198 } ) ;
199+
200+ describe ( 'getMosaicsNames' , ( ) => {
201+ it ( 'should call getMosaicsNames successfully' , ( done ) => {
202+ mosaicHttp . getMosaicsNames ( [ mosaicId ] ) . subscribe ( ( mosaicNames ) => {
203+ expect ( mosaicNames . length ) . to . be . greaterThan ( 0 ) ;
204+ done ( ) ;
205+ } ) ;
206+ } ) ;
207+ } ) ;
208+
209+ /**
210+ * =========================
211+ * House Keeping
212+ * =========================
213+ */
214+ describe ( 'Remove test MosaicAlias' , ( ) => {
215+ let listener : Listener ;
216+ before ( ( ) => {
217+ listener = new Listener ( config . apiUrl ) ;
218+ return listener . open ( ) ;
219+ } ) ;
220+ after ( ( ) => {
221+ return listener . close ( ) ;
222+ } ) ;
223+
224+ it ( 'Announce MosaicAliasTransaction' , ( done ) => {
225+ const mosaicAliasTransaction = MosaicAliasTransaction . create (
226+ Deadline . create ( ) ,
227+ AliasActionType . Link ,
228+ namespaceId ,
229+ mosaicId ,
230+ NetworkType . MIJIN_TEST ,
231+ ) ;
232+ const signedTransaction = mosaicAliasTransaction . signWith ( account ) ;
233+
234+ listener . confirmed ( account . address ) . subscribe ( ( transaction ) => {
235+ done ( ) ;
236+ } ) ;
237+ listener . status ( account . address ) . subscribe ( ( error ) => {
238+ console . log ( 'Error:' , error ) ;
239+ assert ( false ) ;
240+ done ( ) ;
241+ } ) ;
242+ transactionHttp . announce ( signedTransaction ) ;
243+ } ) ;
244+ } ) ;
126245} ) ;
0 commit comments