@@ -293,6 +293,18 @@ describe("Additional registers", () => {
293293 builder = new OutputBuilder ( SAFE_MIN_BOX_VALUE , ergoTreeHex , height ) ;
294294 } ) ;
295295
296+ it ( "should merge additional registers" , ( ) => {
297+ builder . setAdditionalRegisters ( { R4 : "0101" , R6 : "0102" } ) ;
298+ expect ( builder . additionalRegisters ) . toEqual ( { R4 : "0101" , R6 : "0102" } ) ;
299+
300+ expect ( ( ) => builder . build ( ) ) . toThrow ( InvalidRegistersPacking ) ; // R5 is missing
301+
302+ builder . setAdditionalRegisters ( { R5 : "0103" } ) ;
303+ expect ( builder . additionalRegisters ) . toEqual ( { R4 : "0101" , R5 : "0103" , R6 : "0102" } ) ;
304+
305+ expect ( ( ) => builder . build ( ) ) . not . toThrow ( ) ;
306+ } ) ;
307+
296308 it ( "Should bind registers properly" , ( ) => {
297309 builder . setAdditionalRegisters ( {
298310 R4 : "0580c0fc82aa02" ,
@@ -335,28 +347,37 @@ describe("Additional registers", () => {
335347 * R9 without adding register R4 to R8, for example.
336348 */
337349 it ( "Should throw if some register is skipped" , ( ) => {
350+ let outputBuilder = new OutputBuilder ( SAFE_MIN_BOX_VALUE , ergoTreeHex , height ) ;
338351 // R4 not included
339352 expect ( ( ) => {
340- builder . setAdditionalRegisters ( {
341- R5 : "0580c0fc82aa02"
342- } as NonMandatoryRegisters ) ;
353+ outputBuilder
354+ . setAdditionalRegisters ( {
355+ R5 : "0580c0fc82aa02"
356+ } as NonMandatoryRegisters )
357+ . build ( ) ;
343358 } ) . toThrow ( InvalidRegistersPacking ) ;
344359
360+ outputBuilder = new OutputBuilder ( SAFE_MIN_BOX_VALUE , ergoTreeHex , height ) ;
345361 // R5 not included
346362 expect ( ( ) => {
347- builder . setAdditionalRegisters ( {
348- R4 : "0580c0fc82aa02" ,
349- R6 : "0580c0fc82aa02"
350- } as NonMandatoryRegisters ) ;
363+ outputBuilder
364+ . setAdditionalRegisters ( {
365+ R4 : "0580c0fc82aa02" ,
366+ R6 : "0580c0fc82aa02"
367+ } as NonMandatoryRegisters )
368+ . build ( ) ;
351369 } ) . toThrow ( InvalidRegistersPacking ) ;
352370
371+ outputBuilder = new OutputBuilder ( SAFE_MIN_BOX_VALUE , ergoTreeHex , height ) ;
353372 // R5 explicitly set to undefined
354373 expect ( ( ) => {
355- builder . setAdditionalRegisters ( {
356- R4 : "0580c0fc82aa02" ,
357- R5 : undefined ,
358- R6 : "0580c0fc82aa02"
359- } as NonMandatoryRegisters ) ;
374+ outputBuilder
375+ . setAdditionalRegisters ( {
376+ R4 : "0580c0fc82aa02" ,
377+ R5 : undefined ,
378+ R6 : "0580c0fc82aa02"
379+ } as NonMandatoryRegisters )
380+ . build ( ) ;
360381 } ) . toThrow ( InvalidRegistersPacking ) ;
361382 } ) ;
362383} ) ;
0 commit comments