import { hash , getRandomBytes } from '@liskhq/lisk-cryptography' ; import { BlockHeader } from '@liskhq/lisk-chain' ; type DeepPartial < T > = T extends Buffer ? T : T extends Function ? T : T extends object ? { [ P in keyof T ] ? : DeepPartial < T [ P ] > ; } : T ; export const createFakeBlockHeader = ( header ? ) : BlockHeader => ( { id : header ?. id ?? hash ( getRandomBytes ( 8 ) ) , version : 2 , timestamp : header ?. timestamp ?? 32578370 , height : header ?. height ?? 489 , previousBlockID : header ?. previousBlockID ?? hash ( getRandomBytes ( 4 ) ) , generatorPublicKey : header ?. generatorPublicKey ?? getRandomBytes ( 32 ) , reward : BigInt ( 0 ) , transactionRoot : getRandomBytes ( 32 ) , signature : getRandomBytes ( 64 ) , asset : { seedReveal : Buffer . alloc ( 0 ) , maxHeightPreviouslyForged : header ?. asset ?. maxHeightPreviouslyForged ?? 0 , maxHeightPrevoted : header ?. asset ?. maxHeightPrevoted ?? 0 , } , } ) ; export const convertHeader = ( blockHeader ) => ( { ... blockHeader , id : Buffer . from ( blockHeader . id ) , previousBlockID : blockHeader . previousBlockId ? Buffer . from ( blockHeader . previousBlockId ) : Buffer . from ( '' ) , generatorPublicKey : Buffer . from ( blockHeader . generatorPublicKey , 'hex' ) , asset : { maxHeightPrevoted : blockHeader . maxHeightPrevoted , maxHeightPreviouslyForged : blockHeader . maxHeightPreviouslyForged , } , } ) ;