@@ -4,7 +4,8 @@ import * as datasources from "@ensnode/datasources";
44import { type DatasourceName , DatasourceNames , ENSNamespaceIds } from "@ensnode/datasources" ;
55
66import { PluginName } from "../../ensindexer/config/types" ;
7- import { buildBlockNumberRange } from "../blockrange" ;
7+ import { type BlockNumberRangeWithStartBlock , buildBlockNumberRange } from "../blockrange" ;
8+ import type { ChainId } from "../types" ;
89import { buildIndexedBlockranges } from "./indexed-blockranges" ;
910
1011vi . mock ( "@ensnode/datasources" , async ( ) => {
@@ -69,13 +70,13 @@ describe("buildIndexedBlockranges()", () => {
6970 // Act
7071 const result = buildIndexedBlockranges ( ENSNamespaceIds . Mainnet , pluginsRequiredDatasourceNames ) ;
7172
73+ const expectedEntries = new Map < ChainId , BlockNumberRangeWithStartBlock > ( [
74+ [ 1 , buildBlockNumberRange ( 80 , undefined ) ] ,
75+ [ 8453 , buildBlockNumberRange ( 5 , 260 ) ] ,
76+ ] ) ;
77+
7278 // Assert
73- expect ( result ) . toStrictEqual (
74- new Map ( [
75- [ 1 , buildBlockNumberRange ( 80 , 200 ) ] ,
76- [ 8453 , buildBlockNumberRange ( 5 , 260 ) ] ,
77- ] ) ,
78- ) ;
79+ expect ( result ) . toStrictEqual ( expectedEntries ) ;
7980 } ) ;
8081
8182 it ( "keeps endBlock undefined when no contracts define it" , ( ) => {
@@ -110,6 +111,38 @@ describe("buildIndexedBlockranges()", () => {
110111 expect ( result ) . toStrictEqual ( new Map ( [ [ 1 , buildBlockNumberRange ( 90 , undefined ) ] ] ) ) ;
111112 } ) ;
112113
114+ it ( "keeps endBlock undefined when only some contracts define it" , ( ) => {
115+ // Arrange
116+ const basenamesDatasourceConfig : unknown = {
117+ chain : { id : 8453 } ,
118+ contracts : {
119+ registry : { startBlock : 17571480 } ,
120+ reverseRegistrar : { startBlock : 18619035 , endBlock : 35936564 } ,
121+ registrarController : { startBlock : 17575714 } ,
122+ } ,
123+ } ;
124+
125+ const datasourcesByName : Partial <
126+ Record < DatasourceName , ReturnType < typeof datasources . maybeGetDatasource > >
127+ > = {
128+ [ DatasourceNames . Basenames ] : datasourceMock ( basenamesDatasourceConfig ) ,
129+ } ;
130+
131+ maybeGetDatasourceMock . mockImplementation (
132+ ( _namespace , datasourceName ) => datasourcesByName [ datasourceName as DatasourceName ] ,
133+ ) ;
134+
135+ const pluginsRequiredDatasourceNames = new Map ( [
136+ [ PluginName . Basenames , [ DatasourceNames . Basenames ] ] ,
137+ ] ) ;
138+
139+ // Act
140+ const result = buildIndexedBlockranges ( ENSNamespaceIds . Mainnet , pluginsRequiredDatasourceNames ) ;
141+
142+ // Assert
143+ expect ( result ) . toStrictEqual ( new Map ( [ [ 8453 , buildBlockNumberRange ( 17571480 , undefined ) ] ] ) ) ;
144+ } ) ;
145+
113146 it ( "throws when a required datasource is missing" , ( ) => {
114147 // Arrange
115148 maybeGetDatasourceMock . mockReturnValue ( undefined ) ;
0 commit comments