77 NetworkType ,
88 toHex ,
99} from '@metamask/controller-utils' ;
10+ import type { Provider } from '@metamask/eth-query' ;
1011import assert from 'assert' ;
1112import { ethErrors } from 'eth-rpc-errors' ;
1213import type { Patch } from 'immer' ;
@@ -27,10 +28,8 @@ import type {
2728 ProviderConfig ,
2829} from '../src/NetworkController' ;
2930import { NetworkController } from '../src/NetworkController' ;
30- import type { Provider } from '../src/types' ;
3131import { NetworkClientType } from '../src/types' ;
32- import type { FakeProviderStub } from './fake-provider' ;
33- import { FakeProvider } from './fake-provider' ;
32+ import { FakeProvider , type FakeProviderStub } from './fake-provider' ;
3433
3534jest . mock ( '../src/create-network-client' ) ;
3635
@@ -978,9 +977,10 @@ describe('NetworkController', () => {
978977 provider ,
979978 ) ;
980979 const response1 = await promisifiedSendAsync1 ( {
981- id : '1' ,
980+ id : 1 ,
982981 jsonrpc : '2.0' ,
983982 method : 'test' ,
983+ params : [ ] ,
984984 } ) ;
985985 expect ( response1 . result ) . toBe ( 'test response 1' ) ;
986986
@@ -989,9 +989,10 @@ describe('NetworkController', () => {
989989 provider ,
990990 ) ;
991991 const response2 = await promisifiedSendAsync2 ( {
992- id : '2' ,
992+ id : 2 ,
993993 jsonrpc : '2.0' ,
994994 method : 'test' ,
995+ params : [ ] ,
995996 } ) ;
996997 expect ( response2 . result ) . toBe ( 'test response 2' ) ;
997998 } ,
@@ -1072,9 +1073,10 @@ describe('NetworkController', () => {
10721073 provider ,
10731074 ) ;
10741075 const response1 = await promisifiedSendAsync1 ( {
1075- id : '1' ,
1076+ id : 1 ,
10761077 jsonrpc : '2.0' ,
10771078 method : 'test' ,
1079+ params : [ ] ,
10781080 } ) ;
10791081 expect ( response1 . result ) . toBe ( 'test response 1' ) ;
10801082
@@ -1083,9 +1085,10 @@ describe('NetworkController', () => {
10831085 provider ,
10841086 ) ;
10851087 const response2 = await promisifiedSendAsync2 ( {
1086- id : '2' ,
1088+ id : 2 ,
10871089 jsonrpc : '2.0' ,
10881090 method : 'test' ,
1091+ params : [ ] ,
10891092 } ) ;
10901093 expect ( response2 . result ) . toBe ( 'test response 2' ) ;
10911094 } ,
@@ -3134,7 +3137,7 @@ describe('NetworkController', () => {
31343137 } ,
31353138 } ,
31363139 async ( { controller, messenger } ) => {
3137- setFakeProvider ( controller , {
3140+ await setFakeProvider ( controller , {
31383141 stubLookupNetworkWhileSetting : true ,
31393142 } ) ;
31403143 const promiseForNoStateChanges = waitForStateChanges ( {
@@ -4871,10 +4874,10 @@ describe('NetworkController', () => {
48714874 // We only care about the first state change, because it
48724875 // happens before networkDidChange
48734876 count : 1 ,
4874- operation : ( ) => {
4877+ operation : async ( ) => {
48754878 // Intentionally not awaited because we want to check state
48764879 // while this operation is in-progress
4877- controller . rollbackToPreviousProvider ( ) ;
4880+ await controller . rollbackToPreviousProvider ( ) ;
48784881 } ,
48794882 beforeResolving : ( ) => {
48804883 expect (
@@ -4948,9 +4951,10 @@ describe('NetworkController', () => {
49484951 provider ,
49494952 ) ;
49504953 const response = await promisifiedSendAsync ( {
4951- id : '1' ,
4954+ id : 1 ,
49524955 jsonrpc : '2.0' ,
49534956 method : 'test' ,
4957+ params : [ ] ,
49544958 } ) ;
49554959 expect ( response . result ) . toBe ( 'test response' ) ;
49564960 } ,
@@ -5431,10 +5435,10 @@ describe('NetworkController', () => {
54315435 // We only care about the first state change, because it
54325436 // happens before networkDidChange
54335437 count : 1 ,
5434- operation : ( ) => {
5438+ operation : async ( ) => {
54355439 // Intentionally not awaited because we want to check state
54365440 // while this operation is in-progress
5437- controller . rollbackToPreviousProvider ( ) ;
5441+ await controller . rollbackToPreviousProvider ( ) ;
54385442 } ,
54395443 beforeResolving : ( ) => {
54405444 expect (
@@ -5502,9 +5506,10 @@ describe('NetworkController', () => {
55025506 provider ,
55035507 ) ;
55045508 const response = await promisifiedSendAsync ( {
5505- id : '1' ,
5509+ id : 1 ,
55065510 jsonrpc : '2.0' ,
55075511 method : 'test' ,
5512+ params : [ ] ,
55085513 } ) ;
55095514 expect ( response . result ) . toBe ( 'test response' ) ;
55105515 } ,
@@ -7092,14 +7097,14 @@ async function waitForPublishedEvents<E extends NetworkControllerEvents>({
70927097 // the signature of `subscribe` and the way that we're using it. Try
70937098 // changing `any` to either `((...args: E['payload']) => void)` or
70947099 // `ExtractEventHandler<E, E['type']>` to see the issue.
7095- const eventListener : any = ( ...payload : E [ 'payload' ] ) => {
7100+ const eventListener : any = async ( ...payload : E [ 'payload' ] ) => {
70967101 allEventPayloads . push ( payload ) ;
70977102
70987103 if ( isEventPayloadInteresting ( payload ) ) {
70997104 interestingEventPayloads . push ( payload ) ;
71007105 if ( interestingEventPayloads . length === expectedNumberOfEvents ) {
71017106 stopTimer ( ) ;
7102- end ( ) ;
7107+ await end ( ) ;
71037108 } else {
71047109 resetTimer ( ) ;
71057110 }
0 commit comments