1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
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' ;
2826
2927export class IntegrationTestHelper {
30-
28+ public readonly yaml = require ( 'js-yaml' ) ;
3129 public apiUrl : string ;
3230 public repositoryFactory : RepositoryFactory ;
3331 public account : Account ;
@@ -57,7 +55,8 @@ export class IntegrationTestHelper {
5755 console . log ( `Running tests against: ${ json . apiUrl } ` ) ;
5856 this . apiUrl = json . apiUrl ;
5957 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 ] ) => {
6160 this . networkType = networkType ;
6261 this . generationHash = generationHash ;
6362 this . account = this . createAccount ( json . testAccount ) ;
@@ -71,15 +70,18 @@ export class IntegrationTestHelper {
7170 this . harvestingAccount = this . createAccount ( json . harvestingAccount ) ;
7271 this . listener = this . repositoryFactory . createListener ( ) ;
7372
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 ) ;
7675
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 } ` ) ;
8082 return resolve ( this ) ;
8183 } else {
82- const parsedYaml = yaml . safeLoad ( yamlData ) ;
84+ const parsedYaml = this . yaml . safeLoad ( yamlData ) ;
8385 this . account = this . createAccount ( parsedYaml . nemesis_addresses [ 0 ] ) ;
8486 this . account2 = this . createAccount ( parsedYaml . nemesis_addresses [ 1 ] ) ;
8587 this . account3 = this . createAccount ( parsedYaml . nemesis_addresses [ 2 ] ) ;
@@ -91,15 +93,14 @@ export class IntegrationTestHelper {
9193 }
9294 } ) ;
9395 } , ( 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 ) ;
9597 return reject ( error ) ;
9698 } ) ;
9799 } ) ;
98100
99-
100- }
101+ } ,
101102 ) ;
102- } ;
103+ }
103104
104105 createAccount ( data ) : Account {
105106 return Account . createFromPrivateKey ( data . privateKey ? data . privateKey : data . private , this . networkType ) ;
@@ -114,12 +115,12 @@ export class IntegrationTestHelper {
114115 console . log ( `Transaction ${ signedTransaction . type } confirmed` ) ;
115116 resolve ( transaction ) ;
116117 } ) ;
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 ) => {
118119 console . log ( `Error processing transaction ${ signedTransaction . type } ` , error ) ;
119120 reject ( error ) ;
120121 } ) ;
121122 this . repositoryFactory . createTransactionRepository ( ) . announce ( signedTransaction ) ;
122- }
123+ } ,
123124 ) ;
124- } ;
125+ }
125126}
0 commit comments