@@ -28,7 +28,7 @@ describe('Debugging tests', () => {
2828 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
2929
3030 // console.log(ownerSig, owner, num, beef, 1, "test", true);
31- const expectedLog = new RegExp ( `^Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 1000 0xbeef 1 test true$` ) ;
31+ const expectedLog = new RegExp ( `^\\[Input #0] Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 1000 0xbeef 1 test true$` ) ;
3232 expect ( transaction ) . toLog ( expectedLog ) ;
3333 } ) ;
3434
@@ -39,7 +39,7 @@ describe('Debugging tests', () => {
3939 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
4040
4141 // console.log(ownerSig, owner, num, beef, 1, "test", true);
42- const expectedLog = new RegExp ( `^Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100 0xbeef 1 test true$` ) ;
42+ const expectedLog = new RegExp ( `^\\[Input #0] Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100 0xbeef 1 test true$` ) ;
4343 expect ( transaction ) . toLog ( expectedLog ) ;
4444 } ) ;
4545
@@ -49,7 +49,7 @@ describe('Debugging tests', () => {
4949 . addInput ( contractUtxo , contractTestLogs . unlock . transfer ( new SignatureTemplate ( incorrectPriv ) , 1000n ) )
5050 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
5151
52- const expectedLog = new RegExp ( `^Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 1000 0xbeef 1 test true$` ) ;
52+ const expectedLog = new RegExp ( `^\\[Input #0] Test.cash:10 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 1000 0xbeef 1 test true$` ) ;
5353 expect ( transaction ) . not . toLog ( expectedLog ) ;
5454 } ) ;
5555
@@ -58,7 +58,7 @@ describe('Debugging tests', () => {
5858 . addInput ( contractUtxo , contractTestLogs . unlock . secondFunction ( ) )
5959 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
6060
61- expect ( transaction ) . toLog ( new RegExp ( '^Test.cash:16 Hello Second Function$' ) ) ;
61+ expect ( transaction ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:16 Hello Second Function$' ) ) ;
6262 expect ( transaction ) . not . toLog ( / H e l l o F i r s t F u n c t i o n / ) ;
6363 } ) ;
6464
@@ -76,7 +76,7 @@ describe('Debugging tests', () => {
7676 . addInput ( utxo , contractTestMultipleConstructorParameters . unlock . secondFunction ( ) )
7777 . addOutput ( { to : contractTestMultipleConstructorParameters . address , amount : 10000n } ) ;
7878
79- expect ( transaction ) . toLog ( new RegExp ( '^Test.cash:20 Hello Second Function$' ) ) ;
79+ expect ( transaction ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:20 Hello Second Function$' ) ) ;
8080 expect ( transaction ) . not . toLog ( / H e l l o F i r s t F u n c t i o n / ) ;
8181 } ) ;
8282
@@ -85,18 +85,18 @@ describe('Debugging tests', () => {
8585 . addInput ( contractUtxo , contractTestLogs . unlock . functionWithIfStatement ( 1n ) )
8686 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
8787
88- expect ( transaction1 ) . toLog ( new RegExp ( '^Test.cash:24 a is 1$' ) ) ;
89- expect ( transaction1 ) . toLog ( new RegExp ( '^Test.cash:31 a equals 1$' ) ) ;
90- expect ( transaction1 ) . toLog ( new RegExp ( '^Test.cash:32 b equals 1$' ) ) ;
88+ expect ( transaction1 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:24 a is 1$' ) ) ;
89+ expect ( transaction1 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:31 a equals 1$' ) ) ;
90+ expect ( transaction1 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:32 b equals 1$' ) ) ;
9191 expect ( transaction1 ) . not . toLog ( / a i s n o t 1 / ) ;
9292
9393 const transaction2 = new TransactionBuilder ( { provider } )
9494 . addInput ( contractUtxo , contractTestLogs . unlock . functionWithIfStatement ( 2n ) )
9595 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
9696
97- expect ( transaction2 ) . toLog ( new RegExp ( '^Test.cash:27 a is not 1$' ) ) ;
98- expect ( transaction2 ) . toLog ( new RegExp ( '^Test.cash:31 a equals 2$' ) ) ;
99- expect ( transaction2 ) . toLog ( new RegExp ( '^Test.cash:32 b equals 2$' ) ) ;
97+ expect ( transaction2 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:27 a is not 1$' ) ) ;
98+ expect ( transaction2 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:31 a equals 2$' ) ) ;
99+ expect ( transaction2 ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:32 b equals 2$' ) ) ;
100100 expect ( transaction2 ) . not . toLog ( / a i s 1 / ) ;
101101 } ) ;
102102
@@ -111,9 +111,9 @@ describe('Debugging tests', () => {
111111 . addOutput ( { to : contractTestConsecutiveLogs . address , amount : 10000n } ) ;
112112
113113 // console.log(ownerSig, owner, num, beef);
114- expect ( transaction ) . toLog ( new RegExp ( `^Test.cash:9 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100$` ) ) ;
114+ expect ( transaction ) . toLog ( new RegExp ( `^\\[Input #0] Test.cash:9 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100$` ) ) ;
115115 // console.log(1, "test", true)
116- expect ( transaction ) . toLog ( new RegExp ( '^Test.cash:10 0xbeef 1 test true$' ) ) ;
116+ expect ( transaction ) . toLog ( new RegExp ( '^\\[Input #0] Test.cash:10 0xbeef 1 test true$' ) ) ;
117117 } ) ;
118118
119119 it ( 'should log multiple console.log statements with other statements in between' , async ( ) => {
@@ -127,10 +127,10 @@ describe('Debugging tests', () => {
127127 . addOutput ( { to : contractTestMultipleLogs . address , amount : 10000n } ) ;
128128
129129 // console.log(ownerSig, owner, num);
130- const expectedFirstLog = new RegExp ( `^Test.cash:6 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100$` ) ;
130+ const expectedFirstLog = new RegExp ( `^\\[Input #0] Test.cash:6 0x[0-9a-f]{130} 0x${ binToHex ( alicePub ) } 100$` ) ;
131131 expect ( transaction ) . toLog ( expectedFirstLog ) ;
132132
133- const expectedSecondLog = new RegExp ( '^Test.cash:11 0xbeef 1 test true$' ) ;
133+ const expectedSecondLog = new RegExp ( '^\\[Input #0] Test.cash:11 0xbeef 1 test true$' ) ;
134134 expect ( transaction ) . toLog ( expectedSecondLog ) ;
135135 } ) ;
136136
@@ -140,8 +140,8 @@ describe('Debugging tests', () => {
140140 . addInput ( contractUtxo , contractTestLogs . unlock . test_log_inside_notif_statement ( false ) )
141141 . addOutput ( { to : contractTestLogs . address , amount : contractUtxo . satoshis - 1000n } ) ;
142142
143- expect ( transaction ) . toLog ( new RegExp ( `^Test.cash:52 before: ${ contractUtxo . satoshis } $` ) ) ;
144- expect ( transaction ) . toLog ( new RegExp ( `^Test.cash:54 after: ${ contractUtxo . satoshis } $` ) ) ;
143+ expect ( transaction ) . toLog ( new RegExp ( `^\\[Input #0] Test.cash:52 before: ${ contractUtxo . satoshis } $` ) ) ;
144+ expect ( transaction ) . toLog ( new RegExp ( `^\\[Input #0] Test.cash:54 after: ${ contractUtxo . satoshis } $` ) ) ;
145145 } ) ;
146146
147147 it ( 'should log intermediate results that get optimised out' , async ( ) => {
@@ -150,7 +150,7 @@ describe('Debugging tests', () => {
150150 . addOutput ( { to : contractTestLogs . address , amount : 10000n } ) ;
151151
152152 const expectedHash = binToHex ( sha256 ( alicePub ) ) ;
153- expect ( transaction ) . toLog ( new RegExp ( `^Test.cash:43 0x${ expectedHash } $` ) ) ;
153+ expect ( transaction ) . toLog ( new RegExp ( `^\\[Input #0] Test.cash:43 0x${ expectedHash } $` ) ) ;
154154 } ) ;
155155
156156 it . todo ( 'intermediate results that is more complex than the test above' ) ;
@@ -542,7 +542,7 @@ describe('Debugging tests', () => {
542542
543543 expect (
544544 ( ) => expect ( transaction ) . toLog ( '^This is definitely not the log$' ) ,
545- ) . toThrow ( / E x p e c t e d : .* T h i s i s d e f i n i t e l y n o t t h e l o g .* \n R e c e i v e d : ( .| \n ) * ?T e s t .c a s h : 4 H e l l o W o r l d / ) ;
545+ ) . toThrow ( / E x p e c t e d : .* T h i s i s d e f i n i t e l y n o t t h e l o g .* \n R e c e i v e d : ( .| \n ) * ?\[ I n p u t # 0 ] T e s t .c a s h : 4 H e l l o W o r l d / ) ;
546546 } ) ;
547547
548548 it ( 'should fail the JestExtensions test if a log is logged that is NOT expected' , async ( ) => {
@@ -554,12 +554,14 @@ describe('Debugging tests', () => {
554554 . addOutput ( { to : contractTestRequires . address , amount : 10000n } ) ;
555555
556556 expect (
557- ( ) => expect ( transaction ) . not . toLog ( '^Test.cash:4 Hello World$' ) ,
558- ) . toThrow ( / E x p e c t e d : n o t .* T e s t .c a s h : 4 H e l l o W o r l d .* \n R e c e i v e d : ( .| \n ) * ?T e s t .c a s h : 4 H e l l o W o r l d / ) ;
557+ ( ) => expect ( transaction ) . not . toLog ( '^\\[Input #0] Test.cash:4 Hello World$' ) ,
558+ ) . toThrow (
559+ / E x p e c t e d : n o t .* \\ \\ \[ I n p u t # 0 ] T e s t .c a s h : 4 H e l l o W o r l d .* \n R e c e i v e d : ( .| \n ) * ?\[ I n p u t # 0 ] T e s t .c a s h : 4 H e l l o W o r l d / ,
560+ ) ;
559561
560562 expect (
561563 ( ) => expect ( transaction ) . not . toLog ( ) ,
562- ) . toThrow ( / E x p e c t e d : n o t .* u n d e f i n e d .* \n R e c e i v e d : ( .| \n ) * ?T e s t .c a s h : 4 H e l l o W o r l d / ) ;
564+ ) . toThrow ( / E x p e c t e d : n o t .* u n d e f i n e d .* \n R e c e i v e d : ( .| \n ) * ?\[ I n p u t # 0 ] T e s t .c a s h : 4 H e l l o W o r l d / ) ;
563565 } ) ;
564566
565567 it ( 'should fail the JestExtensions test if a log is expected where no log is logged' , async ( ) => {
0 commit comments