@@ -17,7 +17,7 @@ describe('BNS event server tests', () => {
1717 beforeEach ( async ( ) => {
1818 process . env . PG_DATABASE = 'postgres' ;
1919 await cycleMigrations ( ) ;
20- db = await PgWriteStore . connect ( { usageName : 'tests' , withNotifier : false } ) ;
20+ db = await PgWriteStore . connect ( { usageName : 'tests' , withNotifier : true } ) ;
2121 client = db . sql ;
2222 eventServer = await startEventServer ( {
2323 datastore : db ,
@@ -1052,7 +1052,6 @@ describe('BNS event server tests', () => {
10521052 } )
10531053
10541054 test ( 'BNS middleware is async. /new_block posts return before importing BNS finishes' , async ( ) => {
1055- jest . useRealTimers ( ) ;
10561055 process . env . BNS_IMPORT_DIR = 'src/tests-bns/import-test-files' ;
10571056 const genesisBlock = await getGenesisBlockData ( 'src/tests-event-replay/tsv/mainnet.tsv' ) ;
10581057
@@ -1069,15 +1068,15 @@ describe('BNS event server tests', () => {
10691068 expect ( configState . bns_names_onchain_imported ) . toBe ( false )
10701069 expect ( configState . bns_subdomains_imported ) . toBe ( false )
10711070
1072- const timeoutId : NodeJS . Timeout = await new Promise ( resolve => {
1073- const timeoutId = setTimeout ( async ( ) => {
1074- const configState = await db . getConfigState ( ) ;
1075- expect ( configState . bns_names_onchain_imported ) . toBe ( true )
1076- expect ( configState . bns_subdomains_imported ) . toBe ( true )
1077- resolve ( timeoutId )
1078- } , 2000 )
1071+ await new Promise ( resolve => {
1072+ db . eventEmitter . on ( 'configStateUpdate' , ( configState ) => {
1073+ if ( configState . bns_names_onchain_imported && configState . bns_subdomains_imported ) {
1074+ expect ( configState . bns_names_onchain_imported ) . toBe ( true )
1075+ expect ( configState . bns_subdomains_imported ) . toBe ( true ) ;
1076+ resolve ( undefined ) ;
1077+ }
1078+ } )
10791079 } )
1080-
1081- clearTimeout ( timeoutId ) ;
1080+ db . eventEmitter . removeAllListeners ( 'configStateUpdate' ) ;
10821081 } )
10831082} )
0 commit comments