import { expect } from "chai" ; import axios from "axios" ; import { createIBeaconPreset } from "../../src/utils" ; import * as mainnet from "../../src/presets/mainnet" ; import * as minimal from "../../src/presets/minimal" ; import { ForkName } from "../../src" ; import { loadConfigYaml } from "../yaml" ; async function downloadRemoteConfig ( preset , commit ) { const urlByFork = { [ ForkName . phase0 ] : `https://raw.githubusercontent.com/ethereum/eth2.0-specs/${ commit }/presets/${ preset }/phase0.yaml` , [ ForkName . altair ] : `https://raw.githubusercontent.com/ethereum/eth2.0-specs/${ commit }/presets/${ preset }/altair.yaml` , [ ForkName . bellatrix ] : `https://raw.githubusercontent.com/ethereum/eth2.0-specs/${ commit }/presets/${ preset }/bellatrix.yaml` , } ; const downloadedParams = await Promise . all ( Object . values ( urlByFork ) . map ( ( url ) => axios ( { url , timeout : 30 * 1000 } ) . then ( ( response ) => loadConfigYaml ( response . data ) ) ) ) ; const configParams = Object . assign ( ... ( ( downloadedParams as unknown ) as [ input : Record < string , unknown > ] ) ) ; return createIBeaconPreset ( configParams ) ; } describe ( "Ensure config is synced" , function ( ) { this . timeout ( 60 * 1000 ) ; const blacklist = [ "SYNC_COMMITTEE_SIZE" ] ; it ( "mainnet" , async function ( ) { const remotePreset = await downloadRemoteConfig ( "mainnet" , mainnet . commit ) ; const localPreset = { ... mainnet . preset } ; for ( const param of blacklist ) { delete remotePreset [ param ] ; delete ( localPreset as Record < string , unknown > ) [ param ] ; } expect ( localPreset ) . to . deep . equal ( remotePreset ) ; } ) ; it ( "minimal" , async function ( ) { const remotePreset = await downloadRemoteConfig ( "minimal" , minimal . commit ) ; const localPreset = { ... minimal . preset } ; for ( const param of blacklist ) { delete remotePreset [ param ] ; delete ( localPreset as Record < string , unknown > ) [ param ] ; } expect ( localPreset ) . to . deep . equal ( remotePreset ) ; } ) ; } ) ;