1- import { expect } from 'chai' ;
1+ import { assert , expect } from 'chai' ;
2+ import { Convert } from '../../src/core/format/Convert' ;
23import { Listener } from '../../src/infrastructure/Listener' ;
34import { MetadataHttp } from '../../src/infrastructure/MetadataHttp' ;
45import { TransactionHttp } from '../../src/infrastructure/TransactionHttp' ;
@@ -225,14 +226,14 @@ describe('MetadataTransactionService', () => {
225226 MetadataType . Mosaic ,
226227 targetAccount . publicAccount ,
227228 key . toHex ( ) ,
228- newValue + '1 ' ,
229+ newValue + 'delta ' ,
229230 targetAccount . publicAccount ,
230231 mosaicId ,
231232 ) . subscribe ( ( transaction : MosaicMetadataTransaction ) => {
232233 expect ( transaction . type ) . to . be . equal ( TransactionType . MOSAIC_METADATA_TRANSACTION ) ;
233234 expect ( transaction . scopedMetadataKey . toHex ( ) ) . to . be . equal ( key . toHex ( ) ) ;
234- expect ( transaction . valueSizeDelta ) . to . be . equal ( 1 ) ;
235- expect ( transaction . value ) . to . be . equal ( newValue + '1 ' ) ;
235+ expect ( transaction . valueSizeDelta ) . to . be . equal ( 5 ) ;
236+ expect ( transaction . value ) . to . be . equal ( newValue + 'delta ' ) ;
236237 expect ( transaction . targetPublicKey ) . to . be . equal ( targetAccount . publicKey ) ;
237238 expect ( transaction . targetMosaicId . toHex ( ) ) . to . be . equal ( mosaicId . toHex ( ) ) ;
238239 done ( ) ;
@@ -247,18 +248,59 @@ describe('MetadataTransactionService', () => {
247248 MetadataType . Namespace ,
248249 targetAccount . publicAccount ,
249250 key . toHex ( ) ,
250- newValue + '1 ' ,
251+ newValue + 'delta ' ,
251252 targetAccount . publicAccount ,
252253 namespaceId ,
253254 ) . subscribe ( ( transaction : NamespaceMetadataTransaction ) => {
254255 expect ( transaction . type ) . to . be . equal ( TransactionType . NAMESPACE_METADATA_TRANSACTION ) ;
255256 expect ( transaction . scopedMetadataKey . toHex ( ) ) . to . be . equal ( key . toHex ( ) ) ;
256- expect ( transaction . valueSizeDelta ) . to . be . equal ( 1 ) ;
257- expect ( transaction . value ) . to . be . equal ( newValue + '1 ' ) ;
257+ expect ( transaction . valueSizeDelta ) . to . be . equal ( 5 ) ;
258+ expect ( transaction . value ) . to . be . equal ( newValue + 'delta ' ) ;
258259 expect ( transaction . targetPublicKey ) . to . be . equal ( targetAccount . publicKey ) ;
259260 expect ( transaction . targetNamespaceId . toHex ( ) ) . to . be . equal ( namespaceId . toHex ( ) ) ;
260261 done ( ) ;
261262 } ) ;
262263 } ) ;
263264 } ) ;
265+
266+ describe ( 'Announce transaction through service' , ( ) => {
267+ let listener : Listener ;
268+ before ( ( ) => {
269+ listener = new Listener ( config . apiUrl ) ;
270+ return listener . open ( ) ;
271+ } ) ;
272+ after ( ( ) => {
273+ return listener . close ( ) ;
274+ } ) ;
275+ it ( 'should create MosaicMetadataTransaction and announce' , ( done ) => {
276+ const metaDataService = new MetadataTransactionService ( metadataHttp ) ;
277+
278+ return metaDataService . createMetadataTransaction (
279+ deadline ,
280+ NetworkType . MIJIN_TEST ,
281+ MetadataType . Mosaic ,
282+ targetAccount . publicAccount ,
283+ key . toHex ( ) ,
284+ newValue + 'delta' ,
285+ targetAccount . publicAccount ,
286+ mosaicId ,
287+ ) . subscribe ( ( transaction : MosaicMetadataTransaction ) => {
288+ const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
289+ [ transaction . toAggregate ( targetAccount . publicAccount ) ] ,
290+ NetworkType . MIJIN_TEST ,
291+ [ ] ,
292+ ) ;
293+ const signedTransaction = aggregateTransaction . signWith ( targetAccount , generationHash ) ;
294+ listener . confirmed ( targetAccount . address ) . subscribe ( ( ) => {
295+ done ( ) ;
296+ } ) ;
297+ listener . status ( targetAccount . address ) . subscribe ( ( error ) => {
298+ console . log ( 'Error:' , error ) ;
299+ assert ( false ) ;
300+ done ( ) ;
301+ } ) ;
302+ transactionHttp . announce ( signedTransaction ) ;
303+ } ) ;
304+ } ) ;
305+ } ) ;
264306} ) ;
0 commit comments