@@ -508,5 +508,65 @@ describe('Canton Utils - CantonCommand helpers', function () {
508508 it ( 'should throw on type mismatch' , function ( ) {
509509 assert . throws ( ( ) => utils . assertDeepCantonMatch ( { a : 'str' } , { a : 42 } , noInject ) , / m i s m a t c h / ) ;
510510 } ) ;
511+
512+ describe ( 'ISO timestamp vs microsecond string normalisation' , function ( ) {
513+ const isoTs = '2026-06-12T10:00:00.000Z' ;
514+ const isoTsUs = String ( new Date ( isoTs ) . getTime ( ) * 1000 ) ;
515+
516+ it ( 'should pass when ISO timestamp (expected) equals microseconds (actual)' , function ( ) {
517+ assert . doesNotThrow ( ( ) => utils . assertDeepCantonMatch ( isoTs , isoTsUs , noInject ) ) ;
518+ } ) ;
519+
520+ it ( 'should throw timestamp mismatch when microseconds do not correspond to the ISO value' , function ( ) {
521+ const wrongUs = String ( new Date ( isoTs ) . getTime ( ) * 1000 + 1_000_000 ) ;
522+ assert . throws ( ( ) => utils . assertDeepCantonMatch ( isoTs , wrongUs , noInject ) , / t i m e s t a m p m i s m a t c h / ) ;
523+ } ) ;
524+
525+ it ( 'should pass for ISO timestamp nested inside a mint-like choiceArgument object' , function ( ) {
526+ const executeBefore = '2026-06-13T10:00:00.000Z' ;
527+ const executeBeforeUs = String ( new Date ( executeBefore ) . getTime ( ) * 1000 ) ;
528+
529+ const expected = {
530+ expectedAdmin : 'registrar::1220abc' ,
531+ mint : {
532+ instrumentId : { admin : 'registrar::1220abc' , id : 'STGUSD1' } ,
533+ amount : '1000000.0' ,
534+ holder : 'registrar::1220abc' ,
535+ reference : 'mint-stgusd1-12345' ,
536+ requestedAt : isoTs ,
537+ executeBefore : executeBefore ,
538+ meta : { values : { } } ,
539+ } ,
540+ } ;
541+
542+ const actual = {
543+ expectedAdmin : 'registrar::1220abc' ,
544+ mint : {
545+ instrumentId : { admin : 'registrar::1220abc' , id : 'STGUSD1' } ,
546+ amount : '1000000.0000000000' ,
547+ holder : 'registrar::1220abc' ,
548+ reference : 'mint-stgusd1-12345' ,
549+ requestedAt : isoTsUs ,
550+ executeBefore : executeBeforeUs ,
551+ meta : { values : { } } ,
552+ } ,
553+ } ;
554+
555+ assert . doesNotThrow ( ( ) => utils . assertDeepCantonMatch ( expected , actual , noInject ) ) ;
556+ } ) ;
557+
558+ it ( 'should throw when ISO timestamp in nested object does not match microseconds' , function ( ) {
559+ const wrongUs = String ( new Date ( isoTs ) . getTime ( ) * 1000 + 5_000_000 ) ;
560+
561+ const expected = { mint : { requestedAt : isoTs } } ;
562+ const actual = { mint : { requestedAt : wrongUs } } ;
563+
564+ assert . throws ( ( ) => utils . assertDeepCantonMatch ( expected , actual , noInject ) , / t i m e s t a m p m i s m a t c h / ) ;
565+ } ) ;
566+
567+ it ( 'should not treat an arbitrary non-timestamp ISO-like string as a timestamp' , function ( ) {
568+ assert . throws ( ( ) => utils . assertDeepCantonMatch ( 'not-a-timestamp' , isoTsUs , noInject ) , / m i s m a t c h / ) ;
569+ } ) ;
570+ } ) ;
511571 } ) ;
512572} ) ;
0 commit comments