1- import { it , describe } from 'node:test'
2- import assert from 'assert'
1+ import { describe , it , expect } from 'vitest'
32import { loadBlock , loadReceipts } from './helpers/fixture-loader'
43import { MockRpcClient } from './helpers/mock-rpc-client'
54import { Rpc } from '../src/rpc'
@@ -18,10 +17,10 @@ describe('Rpc Class Integration', () => {
1817 const rpc = new Rpc ( { client : mockClient as any } )
1918
2019 const blocks = await rpc . getBlockBatch ( [ 18000000 ] , { transactions : true } )
21- assert . ok ( blocks , 'Blocks should be returned' )
22- assert . equal ( blocks . length , 1 )
23- assert . ok ( blocks [ 0 ] . block , 'Block should have block property' )
24- assert . equal ( blocks [ 0 ] . block . number , fixtureBlock . number )
20+ expect ( blocks ) . toBeTruthy ( )
21+ expect ( blocks . length ) . toEqual ( 1 )
22+ expect ( blocks [ 0 ] . block ) . toBeTruthy ( )
23+ expect ( blocks [ 0 ] . block . number ) . toEqual ( fixtureBlock . number )
2524 } )
2625
2726 it ( 'getBlockBatch without transactions returns blocks with tx hashes only' , async ( ) => {
@@ -35,8 +34,8 @@ describe('Rpc Class Integration', () => {
3534 const rpc = new Rpc ( { client : mockClient as any } )
3635
3736 const blocks = await rpc . getBlockBatch ( [ 18000000 ] )
38- assert . ok ( blocks , 'Blocks should be returned' )
39- assert . equal ( blocks . length , 1 )
37+ expect ( blocks ) . toBeTruthy ( )
38+ expect ( blocks . length ) . toEqual ( 1 )
4039 } )
4140
4241 it ( 'getBlockBatch handles missing blocks' , async ( ) => {
@@ -47,7 +46,7 @@ describe('Rpc Class Integration', () => {
4746 const rpc = new Rpc ( { client : mockClient as any } )
4847
4948 const blocks = await rpc . getBlockBatch ( [ 99999999 ] , { transactions : true } )
50- assert . equal ( blocks . length , 0 , 'Missing blocks should be filtered out' )
49+ expect ( blocks . length ) . toEqual ( 0 )
5150 } )
5251 } )
5352
@@ -65,10 +64,10 @@ describe('Rpc Class Integration', () => {
6564 const rpc = new Rpc ( { client : mockClient as any } )
6665
6766 const blocks = await rpc . getBlockBatch ( [ 18000000 ] , { receipts : true , transactions : true } )
68- assert . ok ( blocks , 'Blocks should be returned' )
69- assert . equal ( blocks . length , 1 )
70- assert . ok ( blocks [ 0 ] . receipts , 'Block should have receipts attached' )
71- assert . ok ( blocks [ 0 ] . receipts ! . length > 0 , 'Receipts should not be empty' )
67+ expect ( blocks ) . toBeTruthy ( )
68+ expect ( blocks . length ) . toEqual ( 1 )
69+ expect ( blocks [ 0 ] . receipts ) . toBeTruthy ( )
70+ expect ( blocks [ 0 ] . receipts ! . length ) . toBeGreaterThan ( 0 )
7271 } )
7372 } )
7473
@@ -86,8 +85,8 @@ describe('Rpc Class Integration', () => {
8685 } )
8786
8887 const blocks = await rpc . getBlockBatch ( [ 18000000 ] , { transactions : true } )
89- assert . ok ( blocks , 'Blocks should be returned after verification' )
90- assert . equal ( blocks . length , 1 )
88+ expect ( blocks ) . toBeTruthy ( )
89+ expect ( blocks . length ) . toEqual ( 1 )
9190 } )
9291
9392 it ( 'verifies transactions root when enabled' , async ( ) => {
@@ -103,8 +102,8 @@ describe('Rpc Class Integration', () => {
103102 } )
104103
105104 const blocks = await rpc . getBlockBatch ( [ 18000000 ] , { transactions : true } )
106- assert . ok ( blocks , 'Blocks should be returned after tx root verification' )
107- assert . equal ( blocks . length , 1 )
105+ expect ( blocks ) . toBeTruthy ( )
106+ expect ( blocks . length ) . toEqual ( 1 )
108107 } )
109108
110109 it ( 'detects invalid block hash' , async ( ) => {
@@ -120,16 +119,9 @@ describe('Rpc Class Integration', () => {
120119 verifyBlockHash : true
121120 } )
122121
123- await assert . rejects (
124- ( ) => rpc . getBlockBatch ( [ 18000000 ] , { transactions : true } ) ,
125- ( error : any ) => {
126- assert . ok (
127- error . message . includes ( 'failed to verify' ) || error . message . includes ( 'hash' ) ,
128- 'Error should be about hash verification'
129- )
130- return true
131- }
132- )
122+ await expect (
123+ rpc . getBlockBatch ( [ 18000000 ] , { transactions : true } )
124+ ) . rejects . toThrow ( )
133125 } )
134126 } )
135127
@@ -147,8 +139,8 @@ describe('Rpc Class Integration', () => {
147139 } )
148140
149141 const blocks = await rpc . getBlockBatch ( [ 50000000 ] , { transactions : true } )
150- assert . ok ( blocks , 'Blocks should be returned' )
151- assert . equal ( blocks . length , 1 )
142+ expect ( blocks ) . toBeTruthy ( )
143+ expect ( blocks . length ) . toEqual ( 1 )
152144 } )
153145
154146 it ( 'handles Arbitrum transaction types correctly' , async ( ) => {
@@ -164,8 +156,8 @@ describe('Rpc Class Integration', () => {
164156 } )
165157
166158 const blocks = await rpc . getBlockBatch ( [ 150000000 ] , { transactions : true } )
167- assert . ok ( blocks , 'Blocks should be returned' )
168- assert . equal ( blocks . length , 1 )
159+ expect ( blocks ) . toBeTruthy ( )
160+ expect ( blocks . length ) . toEqual ( 1 )
169161 } )
170162
171163 it ( 'handles Hyperliquid system transactions correctly' , async ( ) => {
@@ -181,8 +173,8 @@ describe('Rpc Class Integration', () => {
181173 } )
182174
183175 const blocks = await rpc . getBlockBatch ( [ 50000 ] , { transactions : true } )
184- assert . ok ( blocks , 'Blocks should be returned' )
185- assert . equal ( blocks . length , 1 )
176+ expect ( blocks ) . toBeTruthy ( )
177+ expect ( blocks . length ) . toEqual ( 1 )
186178 } )
187179 } )
188180} )
0 commit comments