@@ -11,7 +11,7 @@ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
1111import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice' ;
1212import type { GlobalVariableBuilder } from '@aztec/sequencer-client' ;
1313import { AztecAddress } from '@aztec/stdlib/aztec-address' ;
14- import type { L2BlockSource } from '@aztec/stdlib/block' ;
14+ import { L2Block , type L2BlockSource } from '@aztec/stdlib/block' ;
1515import type { ContractDataSource } from '@aztec/stdlib/contract' ;
1616import { EmptyL1RollupConstants } from '@aztec/stdlib/epoch-helpers' ;
1717import { GasFees } from '@aztec/stdlib/gas' ;
@@ -321,6 +321,36 @@ describe('aztec node', () => {
321321 expect ( await node . getBlockHeader ( 3 ) ) . toEqual ( undefined ) ;
322322 } ) ;
323323 } ) ;
324+
325+ describe ( 'getBlock' , ( ) => {
326+ let block1 : L2Block ;
327+ let block2 : L2Block ;
328+
329+ beforeEach ( ( ) => {
330+ block1 = L2Block . empty ( ) ;
331+ block2 = L2Block . empty ( ) ;
332+
333+ l2BlockSource . getBlockNumber . mockResolvedValue ( 2 ) ;
334+ } ) ;
335+
336+ it ( 'returns requested block number' , async ( ) => {
337+ l2BlockSource . getBlock . mockResolvedValue ( block1 ) ;
338+ expect ( await node . getBlock ( 1 ) ) . toEqual ( block1 ) ;
339+ expect ( l2BlockSource . getBlock ) . toHaveBeenCalledWith ( 1 ) ;
340+ } ) ;
341+
342+ it ( 'returns latest block' , async ( ) => {
343+ l2BlockSource . getBlock . mockResolvedValue ( block2 ) ;
344+ expect ( await node . getBlock ( 'latest' ) ) . toEqual ( block2 ) ;
345+ expect ( l2BlockSource . getBlock ) . toHaveBeenCalledWith ( 2 ) ;
346+ } ) ;
347+
348+ it ( 'returns undefined for non-existent block' , async ( ) => {
349+ l2BlockSource . getBlock . mockResolvedValue ( undefined ) ;
350+ expect ( await node . getBlock ( 3 ) ) . toEqual ( undefined ) ;
351+ expect ( l2BlockSource . getBlock ) . toHaveBeenCalledWith ( 3 ) ;
352+ } ) ;
353+ } ) ;
324354 } ) ;
325355
326356 describe ( 'simulatePublicCalls' , ( ) => {
0 commit comments