13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- import { Account } from "../../src/model/account/Account" ;
17
- import { RepositoryFactoryHttp } from "../../src/infrastructure/RepositoryFactoryHttp" ;
18
- import { RepositoryFactory } from "../../src/infrastructure/RepositoryFactory" ;
19
- import { NetworkType } from "../../src/model/blockchain/NetworkType" ;
20
- import { combineLatest } from "rxjs" ;
21
- import { IListener } from "../../src/infrastructure/IListener" ;
22
- import { SignedTransaction } from "../../src/model/transaction/SignedTransaction" ;
23
- import { filter } from "rxjs/operators" ;
24
- import { Transaction } from "../../src/model/transaction/Transaction" ;
25
- import { UInt64 } from "../../src/model/UInt64" ;
26
-
27
- const yaml = require ( 'js-yaml' ) ;
16
+ import { combineLatest } from 'rxjs' ;
17
+ import { filter } from 'rxjs/operators' ;
18
+ import { IListener } from '../../src/infrastructure/IListener' ;
19
+ import { RepositoryFactory } from '../../src/infrastructure/RepositoryFactory' ;
20
+ import { RepositoryFactoryHttp } from '../../src/infrastructure/RepositoryFactoryHttp' ;
21
+ import { Account } from '../../src/model/account/Account' ;
22
+ import { NetworkType } from '../../src/model/blockchain/NetworkType' ;
23
+ import { SignedTransaction } from '../../src/model/transaction/SignedTransaction' ;
24
+ import { Transaction } from '../../src/model/transaction/Transaction' ;
25
+ import { UInt64 } from '../../src/model/UInt64' ;
28
26
29
27
export class IntegrationTestHelper {
30
-
28
+ public readonly yaml = require ( 'js-yaml' ) ;
31
29
public apiUrl : string ;
32
30
public repositoryFactory : RepositoryFactory ;
33
31
public account : Account ;
@@ -57,7 +55,8 @@ export class IntegrationTestHelper {
57
55
console . log ( `Running tests against: ${ json . apiUrl } ` ) ;
58
56
this . apiUrl = json . apiUrl ;
59
57
this . repositoryFactory = new RepositoryFactoryHttp ( json . apiUrl ) ;
60
- combineLatest ( this . repositoryFactory . getGenerationHash ( ) , this . repositoryFactory . getNetworkType ( ) ) . subscribe ( ( [ generationHash , networkType ] ) => {
58
+ combineLatest ( this . repositoryFactory . getGenerationHash ( ) ,
59
+ this . repositoryFactory . getNetworkType ( ) ) . subscribe ( ( [ generationHash , networkType ] ) => {
61
60
this . networkType = networkType ;
62
61
this . generationHash = generationHash ;
63
62
this . account = this . createAccount ( json . testAccount ) ;
@@ -71,15 +70,18 @@ export class IntegrationTestHelper {
71
70
this . harvestingAccount = this . createAccount ( json . harvestingAccount ) ;
72
71
this . listener = this . repositoryFactory . createListener ( ) ;
73
72
74
- this . maxFee = UInt64 . fromUint ( 1000000 ) ; // What would be the best maxFee? In the future we will load the fee multiplier from rest.
75
-
73
+ // What would be the best maxFee? In the future we will load the fee multiplier from rest.
74
+ this . maxFee = UInt64 . fromUint ( 1000000 ) ;
76
75
77
- require ( 'fs' ) . readFile ( path . resolve ( __dirname , '../../../catapult-service-bootstrap/build/generated-addresses/addresses.yaml' ) , ( err , yamlData ) => {
78
- if ( err ) {
79
- console . log ( `catapult-service-bootstrap generated address could not be loaded. Ignoring and using accounts from network.conf. Error: ${ err } ` ) ;
76
+ require ( 'fs' ) . readFile ( path . resolve ( __dirname ,
77
+ '../../../catapult-service-bootstrap/build/generated-addresses/addresses.yaml' ) ,
78
+ ( error : any , yamlData : any ) => {
79
+ if ( error ) {
80
+ console . log ( `catapult-service-bootstrap generated address could not be loaded.
81
+ Ignoring and using accounts from network.conf. Error: ${ error } ` ) ;
80
82
return resolve ( this ) ;
81
83
} else {
82
- const parsedYaml = yaml . safeLoad ( yamlData ) ;
84
+ const parsedYaml = this . yaml . safeLoad ( yamlData ) ;
83
85
this . account = this . createAccount ( parsedYaml . nemesis_addresses [ 0 ] ) ;
84
86
this . account2 = this . createAccount ( parsedYaml . nemesis_addresses [ 1 ] ) ;
85
87
this . account3 = this . createAccount ( parsedYaml . nemesis_addresses [ 2 ] ) ;
@@ -91,15 +93,14 @@ export class IntegrationTestHelper {
91
93
}
92
94
} ) ;
93
95
} , ( error ) => {
94
- console . log ( " There has been an error loading the configuration. " , error )
96
+ console . log ( ' There has been an error loading the configuration. ' , error ) ;
95
97
return reject ( error ) ;
96
98
} ) ;
97
99
} ) ;
98
100
99
-
100
- }
101
+ } ,
101
102
) ;
102
- } ;
103
+ }
103
104
104
105
createAccount ( data ) : Account {
105
106
return Account . createFromPrivateKey ( data . privateKey ? data . privateKey : data . private , this . networkType ) ;
@@ -114,12 +115,12 @@ export class IntegrationTestHelper {
114
115
console . log ( `Transaction ${ signedTransaction . type } confirmed` ) ;
115
116
resolve ( transaction ) ;
116
117
} ) ;
117
- this . listener . status ( address ) . pipe ( filter ( status => status . hash === signedTransaction . hash ) ) . subscribe ( ( error ) => {
118
+ this . listener . status ( address ) . pipe ( filter ( ( status ) => status . hash === signedTransaction . hash ) ) . subscribe ( ( error ) => {
118
119
console . log ( `Error processing transaction ${ signedTransaction . type } ` , error ) ;
119
120
reject ( error ) ;
120
121
} ) ;
121
122
this . repositoryFactory . createTransactionRepository ( ) . announce ( signedTransaction ) ;
122
- }
123
+ } ,
123
124
) ;
124
- } ;
125
+ }
125
126
}
0 commit comments