@@ -124,62 +124,43 @@ describe("`debug_traceTransaction` tests to verify `callTracer` usage logic", ()
124124 it ( "should trace block by number and hash" , async ( ) => {
125125 const [ alice , _ ] = devClients ;
126126
127- const totalTxs = 3 ;
128- const txsPromises : any [ ] = [ ] ;
129-
130- const nonce = await publicClient . getTransactionCount ( {
131- address : alice . account . address ,
127+ const txHash = await alice . sendTransaction ( {
128+ to : callerAddress ,
129+ data : encodeFunctionData ( {
130+ abi : caller . abi ,
131+ functionName : "someAction" ,
132+ args : [ calleeAddress , 7n ] ,
133+ } ) ,
132134 } ) ;
133-
134- for ( let numTxs = 0 ; numTxs < totalTxs ; numTxs ++ ) {
135- const txsPromise = alice
136- . sendTransaction ( {
137- to : callerAddress ,
138- data : encodeFunctionData ( {
139- abi : caller . abi ,
140- functionName : "someAction" ,
141- args : [ calleeAddress , 7n ] ,
142- } ) ,
143- gas : 100_000n ,
144- nonce : nonce + numTxs ,
145- } )
146- . then ( ( txHash ) =>
147- publicClient . waitForTransactionReceipt ( {
148- hash : txHash ,
149- timeout : 18_000 ,
150- } ) ,
151- ) ;
152-
153- txsPromises . push ( txsPromise ) ;
154- }
155-
156- const txsReceipts = await Promise . all ( txsPromises ) ;
157-
158- const blockNumberHex = txsReceipts [ 0 ] . blockNumber . toString ( 16 ) ;
159- const blockHash = txsReceipts [ 0 ] . blockHash ;
135+ const txReceipt = await publicClient . waitForTransactionReceipt ( {
136+ hash : txHash ,
137+ } ) ;
138+ const blockNumberHex = txReceipt . blockNumber . toString ( 16 ) ;
139+ const blockHash = txReceipt . blockHash ;
160140
161141 // Trace block by number.
162142 const responseByNumber = await customRpcRequest (
163143 node . meta . rpcUrlHttp ,
164144 "debug_traceBlockByNumber" ,
165145 [ blockNumberHex , { tracer : "callTracer" } ] ,
166146 ) ;
167- expect ( responseByNumber . length ) . to . be . equal ( 3 ) ;
168- responseByNumber . forEach ( ( trace : { [ key : string ] : any } , index : number ) => {
169- expect ( trace [ "txHash" ] ) . to . be . equal ( txsReceipts [ index ] . transactionHash ) ;
170- expect ( trace [ "result" ] . calls . length ) . to . be . equal ( 1 ) ;
171- expect ( Object . keys ( trace [ "result" ] ) . sort ( ) ) . to . deep . equal ( [
172- "calls" ,
173- "from" ,
174- "gas" ,
175- "gasUsed" ,
176- "input" ,
177- "output" ,
178- "to" ,
179- "type" ,
180- "value" ,
181- ] ) ;
182- } ) ;
147+
148+ expect ( responseByNumber . length ) . to . be . equal ( 1 ) ;
149+ expect ( responseByNumber [ 0 ] [ "txHash" ] ) . to . be . equal (
150+ txReceipt . transactionHash ,
151+ ) ;
152+ expect ( responseByNumber [ 0 ] [ "result" ] . calls . length ) . to . be . equal ( 1 ) ;
153+ expect ( Object . keys ( responseByNumber [ 0 ] [ "result" ] ) . sort ( ) ) . to . deep . equal ( [
154+ "calls" ,
155+ "from" ,
156+ "gas" ,
157+ "gasUsed" ,
158+ "input" ,
159+ "output" ,
160+ "to" ,
161+ "type" ,
162+ "value" ,
163+ ] ) ;
183164
184165 // Trace block by hash (actually the rpc method is an alias of `debug_traceBlockByNumber`).
185166 const responseByHash = await customRpcRequest (
@@ -188,20 +169,18 @@ describe("`debug_traceTransaction` tests to verify `callTracer` usage logic", ()
188169 [ blockHash , { tracer : "callTracer" } ] ,
189170 ) ;
190171 expect ( responseByHash . length ) . to . be . equal ( 3 ) ;
191- responseByHash . forEach ( ( trace : { [ key : string ] : any } , index : number ) => {
192- expect ( trace [ "txHash" ] ) . to . be . equal ( txsReceipts [ index ] . transactionHash ) ;
193- expect ( trace [ "result" ] . calls . length ) . to . be . equal ( 1 ) ;
194- expect ( Object . keys ( trace [ "result" ] ) . sort ( ) ) . to . deep . equal ( [
195- "calls" ,
196- "from" ,
197- "gas" ,
198- "gasUsed" ,
199- "input" ,
200- "output" ,
201- "to" ,
202- "type" ,
203- "value" ,
204- ] ) ;
205- } ) ;
172+ expect ( responseByHash [ 0 ] [ "txHash" ] ) . to . be . equal ( txReceipt . transactionHash ) ;
173+ expect ( responseByHash [ 0 ] [ "result" ] . calls . length ) . to . be . equal ( 1 ) ;
174+ expect ( Object . keys ( responseByHash [ 0 ] [ "result" ] ) . sort ( ) ) . to . deep . equal ( [
175+ "calls" ,
176+ "from" ,
177+ "gas" ,
178+ "gasUsed" ,
179+ "input" ,
180+ "output" ,
181+ "to" ,
182+ "type" ,
183+ "value" ,
184+ ] ) ;
206185 } ) ;
207186} ) ;
0 commit comments