@@ -33,58 +33,50 @@ import { MultisigAccountModificationTransaction } from '../../src/model/transact
3333import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction' ;
3434import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
3535import { UInt64 } from '../../src/model/UInt64' ;
36- import { RepositoryFactory } from "../../src/infrastructure/RepositoryFactory" ;
37- import { Config } from "./Config" ;
36+ import { IntegrationTestHelper } from "./IntegrationTestHelper" ;
3837
3938describe ( 'AccountHttp' , ( ) => {
39+ let helper = new IntegrationTestHelper ( ) ;
4040 let account : Account ;
4141 let account2 : Account ;
42- let account3 : Account ;
4342 let multisigAccount : Account ;
4443 let cosignAccount1 : Account ;
4544 let cosignAccount2 : Account ;
4645 let cosignAccount3 : Account ;
4746 let accountAddress : Address ;
4847 let accountPublicKey : string ;
4948 let publicAccount : PublicAccount ;
50- let repositoryFactory : RepositoryFactory ;
5149 let accountRepository : AccountRepository ;
5250 let multisigRepository : MultisigRepository ;
5351 let namespaceRepository : NamespaceRepository ;
5452 let namespaceId : NamespaceId ;
5553 let generationHash : string ;
5654 let networkType : NetworkType ;
57- let config : Config ;
58- let maxFee = UInt64 . fromUint ( 1000000 ) ;
5955
60- before ( ( done ) => {
61-
62- config = new Config ( ( ) => {
63- account = config . account ;
64- account2 = config . account2 ;
65- account3 = config . account3 ;
66- multisigAccount = config . multisigAccount ;
67- cosignAccount1 = config . cosignAccount1 ;
68- cosignAccount2 = config . cosignAccount2 ;
69- cosignAccount3 = config . cosignAccount3 ;
70- accountAddress = config . account . address ;
71- accountPublicKey = config . account . publicKey ;
72- publicAccount = config . account . publicAccount ;
73- generationHash = config . generationHash ;
74- networkType = config . networkType ;
75- repositoryFactory = config . repositoryFactory ;
76- accountRepository = repositoryFactory . createAccountRepository ( ) ;
77- multisigRepository = repositoryFactory . createMultisigRepository ( ) ;
78- namespaceRepository = repositoryFactory . createNamespaceRepository ( ) ;
79- done ( ) ;
56+ before ( ( ) => {
57+ return helper . start ( ) . then ( ( ) => {
58+ account = helper . account ;
59+ account2 = helper . account2 ;
60+ multisigAccount = helper . multisigAccount ;
61+ cosignAccount1 = helper . cosignAccount1 ;
62+ cosignAccount2 = helper . cosignAccount2 ;
63+ cosignAccount3 = helper . cosignAccount3 ;
64+ accountAddress = helper . account . address ;
65+ accountPublicKey = helper . account . publicKey ;
66+ publicAccount = helper . account . publicAccount ;
67+ generationHash = helper . generationHash ;
68+ networkType = helper . networkType ;
69+ accountRepository = helper . repositoryFactory . createAccountRepository ( ) ;
70+ multisigRepository = helper . repositoryFactory . createMultisigRepository ( ) ;
71+ namespaceRepository = helper . repositoryFactory . createNamespaceRepository ( ) ;
8072 } ) ;
8173 } ) ;
8274 before ( ( ) => {
83- return config . listener . open ( ) ;
75+ return helper . listener . open ( ) ;
8476 } ) ;
8577
8678 after ( ( ) => {
87- config . listener . close ( ) ;
79+ helper . listener . close ( ) ;
8880 } ) ;
8981 afterEach ( ( done ) => {
9082 // cold down
@@ -98,55 +90,56 @@ describe('AccountHttp', () => {
9890 */
9991
10092 describe ( 'Make sure test account is not virgin' , ( ) => {
101- it ( 'Announce TransferTransaction' , ( done ) => {
93+ it ( 'Announce TransferTransaction' , ( ) => {
10294 const transferTransaction = TransferTransaction . create (
10395 Deadline . create ( ) ,
10496 account2 . address ,
10597 [ NetworkCurrencyMosaic . createAbsolute ( 1 ) ] ,
10698 PlainMessage . create ( 'test-message' ) ,
10799 networkType ,
108- maxFee
100+ helper . maxFee
109101 ) ;
110102
111103 const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
112- config . announceTransaction ( signedTransaction , done ) ;
104+ return helper . announce ( signedTransaction ) ;
113105 } ) ;
114106 } ) ;
115107
116108 describe ( 'Setup test NamespaceId' , ( ) => {
117- it ( 'Announce NamespaceRegistrationTransaction' , ( done ) => {
109+ it ( 'Announce NamespaceRegistrationTransaction' , ( ) => {
118110 const namespaceName = 'root-test-namespace-' + Math . floor ( Math . random ( ) * 10000 ) ;
119111 const registerNamespaceTransaction = NamespaceRegistrationTransaction . createRootNamespace (
120112 Deadline . create ( ) ,
121113 namespaceName ,
122114 UInt64 . fromUint ( 9 ) ,
123115 networkType ,
124- maxFee
116+ helper . maxFee
125117 ) ;
126118 namespaceId = new NamespaceId ( namespaceName ) ;
127119 const signedTransaction = registerNamespaceTransaction . signWith ( account , generationHash ) ;
128- config . announceTransaction ( signedTransaction , done ) ;
120+ return helper . announce ( signedTransaction ) ;
129121 } ) ;
130122 } ) ;
131123
132124 describe ( 'Setup test AddressAlias' , ( ) => {
133125
134- it ( 'Announce addressAliasTransaction' , ( done ) => {
126+ it ( 'Announce addressAliasTransaction' , ( ) => {
135127 const addressAliasTransaction = AddressAliasTransaction . create (
136128 Deadline . create ( ) ,
137129 AliasAction . Link ,
138130 namespaceId ,
139131 account . address ,
140- networkType , maxFee ,
132+ networkType ,
133+ helper . maxFee ,
141134 ) ;
142135 const signedTransaction = addressAliasTransaction . signWith ( account , generationHash ) ;
143- config . announceTransaction ( signedTransaction , done ) ;
136+ return helper . announce ( signedTransaction ) ;
144137 } ) ;
145138 } ) ;
146139
147140 describe ( 'Setup test multisig account' , ( ) => {
148141
149- it ( 'Announce MultisigAccountModificationTransaction' , ( done ) => {
142+ it ( 'Announce MultisigAccountModificationTransaction' , ( ) => {
150143 const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction . create (
151144 Deadline . create ( ) ,
152145 2 ,
@@ -157,18 +150,19 @@ describe('AccountHttp', () => {
157150 cosignAccount3 . publicAccount ,
158151 ] ,
159152 [ ] ,
160- networkType , maxFee ,
153+ networkType ,
154+ helper . maxFee ,
161155 ) ;
162156
163157 const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
164158 [ modifyMultisigAccountTransaction . toAggregate ( multisigAccount . publicAccount ) ] ,
165159 networkType ,
166160 [ ] ,
167- maxFee ) ;
161+ helper . maxFee ) ;
168162 const signedTransaction = aggregateTransaction
169163 . signTransactionWithCosignatories ( multisigAccount , [ cosignAccount1 , cosignAccount2 , cosignAccount3 ] , generationHash ) ;
170164
171- config . announceTransaction ( signedTransaction , done ) ;
165+ return helper . announce ( signedTransaction ) ;
172166 } ) ;
173167 } ) ;
174168
@@ -268,22 +262,22 @@ describe('AccountHttp', () => {
268262 * =========================
269263 */
270264 describe ( 'Remove test AddressAlias' , ( ) => {
271- it ( 'Announce addressAliasTransaction' , ( done ) => {
265+ it ( 'Announce addressAliasTransaction' , ( ) => {
272266 const addressAliasTransaction = AddressAliasTransaction . create (
273267 Deadline . create ( ) ,
274268 AliasAction . Unlink ,
275269 namespaceId ,
276270 account . address ,
277271 networkType ,
278- maxFee
272+ helper . maxFee
279273 ) ;
280274 const signedTransaction = addressAliasTransaction . signWith ( account , generationHash ) ;
281- config . announceTransaction ( signedTransaction , done ) ;
275+ return helper . announce ( signedTransaction ) ;
282276 } ) ;
283277 } ) ;
284278
285279 describe ( 'Restore test multisig Accounts' , ( ) => {
286- it ( 'Announce MultisigAccountModificationTransaction' , ( done ) => {
280+ it ( 'Announce MultisigAccountModificationTransaction' , ( ) => {
287281 const removeCosigner1 = MultisigAccountModificationTransaction . create (
288282 Deadline . create ( ) ,
289283 - 1 ,
@@ -292,7 +286,7 @@ describe('AccountHttp', () => {
292286 [ cosignAccount1 . publicAccount ,
293287 ] ,
294288 networkType ,
295- maxFee
289+ helper . maxFee
296290 ) ;
297291 const removeCosigner2 = MultisigAccountModificationTransaction . create (
298292 Deadline . create ( ) ,
@@ -303,7 +297,7 @@ describe('AccountHttp', () => {
303297 cosignAccount2 . publicAccount ,
304298 ] ,
305299 networkType ,
306- maxFee
300+ helper . maxFee
307301 ) ;
308302
309303 const removeCosigner3 = MultisigAccountModificationTransaction . create (
@@ -315,18 +309,18 @@ describe('AccountHttp', () => {
315309 cosignAccount3 . publicAccount ,
316310 ] ,
317311 networkType ,
318- maxFee
312+ helper . maxFee
319313 ) ;
320314
321315 const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
322316 [ removeCosigner1 . toAggregate ( multisigAccount . publicAccount ) ,
323317 removeCosigner2 . toAggregate ( multisigAccount . publicAccount ) ,
324318 removeCosigner3 . toAggregate ( multisigAccount . publicAccount ) ] ,
325319 networkType ,
326- [ ] , maxFee ) ;
320+ [ ] , helper . maxFee ) ;
327321 const signedTransaction = aggregateTransaction
328322 . signTransactionWithCosignatories ( cosignAccount1 , [ cosignAccount2 , cosignAccount3 ] , generationHash ) ;
329- config . announceTransaction ( signedTransaction , done ) ;
323+ return helper . announce ( signedTransaction ) ;
330324 } ) ;
331325 } ) ;
332326} ) ;
0 commit comments