@@ -15,6 +15,7 @@ import * as Codec from "@truffle/codec";
15
15
import Web3 from "web3" ;
16
16
17
17
import txlog from "lib/txlog/selectors" ;
18
+ import trace from "lib/trace/selectors" ;
18
19
19
20
const __TXLOG = `
20
21
//SPDX-License-Identifier: MIT
@@ -220,6 +221,7 @@ describe("Transaction log (visualizer)", function () {
220
221
verifyNoIntermediates ( untied ) ;
221
222
222
223
const root = bugger . view ( txlog . views . transactionLog ) ;
224
+ const steps = bugger . view ( trace . steps ) . length ;
223
225
assert . equal ( root . type , "transaction" ) ;
224
226
assert . lengthOf ( root . actions , 1 ) ;
225
227
let call = root . actions [ 0 ] ;
@@ -229,6 +231,8 @@ describe("Transaction log (visualizer)", function () {
229
231
assert . equal ( call . functionName , "testCall" ) ;
230
232
assert . equal ( call . contractName , "VizTest" ) ;
231
233
assert . equal ( call . returnKind , "return" ) ;
234
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
235
+ assert . equal ( call . endStep , steps - 1 ) ;
232
236
const expectedSelector = Web3 . utils
233
237
. soliditySha3 ( "testCall(uint256)" )
234
238
. slice ( 0 , 2 + 2 * Codec . Evm . Utils . SELECTOR_SIZE ) ;
@@ -256,6 +260,11 @@ describe("Transaction log (visualizer)", function () {
256
260
assert . equal ( call . functionName , "called" ) ;
257
261
assert . equal ( call . contractName , "VizTest" ) ;
258
262
assert . equal ( call . returnKind , "return" ) ;
263
+ assert . isAbove (
264
+ call . endStep ,
265
+ call . beginStep ,
266
+ "beginStep should precede endStep for non-instant calls"
267
+ ) ;
259
268
inputs = Codec . Export . unsafeNativizeVariables ( byName ( call . arguments ) ) ;
260
269
assert . deepEqual ( inputs , {
261
270
x : 108
@@ -282,6 +291,7 @@ describe("Transaction log (visualizer)", function () {
282
291
verifyNoIntermediates ( untied ) ;
283
292
284
293
const root = bugger . view ( txlog . views . transactionLog ) ;
294
+ const steps = bugger . view ( trace . steps ) . length ;
285
295
assert . equal ( root . type , "transaction" ) ;
286
296
assert . lengthOf ( root . actions , 1 ) ;
287
297
let call = root . actions [ 0 ] ;
@@ -291,6 +301,8 @@ describe("Transaction log (visualizer)", function () {
291
301
assert . isUndefined ( call . functionName ) ;
292
302
assert . equal ( call . contractName , "Secondary" ) ;
293
303
assert . equal ( call . returnKind , "return" ) ;
304
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
305
+ assert . equal ( call . endStep , steps - 1 ) ;
294
306
const expectedBytecode = abstractions . Secondary . binary ;
295
307
const expectedArgument = Codec . Conversion . toHexString (
296
308
108 ,
@@ -316,6 +328,11 @@ describe("Transaction log (visualizer)", function () {
316
328
assert . equal ( call . functionName , "another" ) ;
317
329
assert . equal ( call . contractName , "Secondary" ) ;
318
330
assert . equal ( call . returnKind , "return" ) ;
331
+ assert . isAbove (
332
+ call . endStep ,
333
+ call . beginStep ,
334
+ "beginStep should precede endStep for non-instant calls"
335
+ ) ;
319
336
assert . lengthOf ( call . arguments , 0 ) ;
320
337
outputs = Codec . Export . unsafeNativizeVariables ( byName ( call . returnValues ) ) ;
321
338
assert . include ( outputs , {
@@ -341,6 +358,7 @@ describe("Transaction log (visualizer)", function () {
341
358
verifyNoIntermediates ( untied ) ;
342
359
343
360
const root = bugger . view ( txlog . views . transactionLog ) ;
361
+ const steps = bugger . view ( trace . steps ) . length ;
344
362
assert . equal ( root . type , "transaction" ) ;
345
363
assert . lengthOf ( root . actions , 1 ) ;
346
364
let call = root . actions [ 0 ] ;
@@ -352,6 +370,8 @@ describe("Transaction log (visualizer)", function () {
352
370
assert . equal ( call . returnKind , "return" ) ;
353
371
assert . lengthOf ( call . arguments , 0 ) ;
354
372
assert . lengthOf ( call . returnValues , 0 ) ;
373
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
374
+ assert . equal ( call . endStep , steps - 1 ) ;
355
375
assert . lengthOf ( call . actions , 1 ) ;
356
376
call = call . actions [ 0 ] ;
357
377
assert . equal ( call . type , "callexternal" ) ;
@@ -361,6 +381,11 @@ describe("Transaction log (visualizer)", function () {
361
381
assert . equal ( call . functionName , "loudIncrement" ) ;
362
382
assert . equal ( call . contractName , "VizLibrary" ) ;
363
383
assert . equal ( call . returnKind , "return" ) ;
384
+ assert . isAbove (
385
+ call . endStep ,
386
+ call . beginStep ,
387
+ "beginStep should precede endStep for non-instant calls"
388
+ ) ;
364
389
let inputs = Codec . Export . unsafeNativizeVariables ( byName ( call . arguments ) ) ;
365
390
assert . deepEqual ( inputs , {
366
391
x : 1
@@ -390,6 +415,7 @@ describe("Transaction log (visualizer)", function () {
390
415
verifyNoIntermediates ( untied ) ;
391
416
392
417
const root = bugger . view ( txlog . views . transactionLog ) ;
418
+ const steps = bugger . view ( trace . steps ) . length ;
393
419
assert . equal ( root . type , "transaction" ) ;
394
420
let origin = root . origin ;
395
421
assert . lengthOf ( root . actions , 1 ) ;
@@ -403,12 +429,19 @@ describe("Transaction log (visualizer)", function () {
403
429
assert . lengthOf ( call . arguments , 0 ) ;
404
430
assert . lengthOf ( call . returnValues , 0 ) ;
405
431
assert . lengthOf ( call . actions , 1 ) ;
432
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
433
+ assert . equal ( call . endStep , steps - 1 ) ;
406
434
call = call . actions [ 0 ] ;
407
435
assert . equal ( call . type , "callexternal" ) ;
408
436
assert . equal ( call . kind , "message" ) ;
409
437
assert . equal ( call . address , origin ) ;
410
438
assert . equal ( call . value . toNumber ( ) , 1 ) ;
411
439
assert . equal ( call . returnKind , "return" ) ;
440
+ assert . equal (
441
+ call . endStep ,
442
+ call . beginStep ,
443
+ "beginStep should equal endStep for instant calls"
444
+ ) ;
412
445
} ) ;
413
446
414
447
it ( "Correctly logs a fallback call" , async function ( ) {
@@ -428,6 +461,7 @@ describe("Transaction log (visualizer)", function () {
428
461
verifyNoIntermediates ( untied ) ;
429
462
430
463
const root = bugger . view ( txlog . views . transactionLog ) ;
464
+ const steps = bugger . view ( trace . steps ) . length ;
431
465
assert . equal ( root . type , "transaction" ) ;
432
466
assert . lengthOf ( root . actions , 1 ) ;
433
467
let call = root . actions [ 0 ] ;
@@ -439,11 +473,18 @@ describe("Transaction log (visualizer)", function () {
439
473
assert . equal ( call . returnKind , "return" ) ;
440
474
assert . equal ( call . returnData , "0xbeefdead" ) ;
441
475
assert . lengthOf ( call . actions , 1 ) ;
476
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
477
+ assert . equal ( call . endStep , steps - 1 ) ;
442
478
call = call . actions [ 0 ] ;
443
479
assert . equal ( call . type , "callinternal" ) ;
444
480
assert . equal ( call . functionName , "called" ) ;
445
481
assert . equal ( call . contractName , "VizTest" ) ;
446
482
assert . equal ( call . returnKind , "return" ) ;
483
+ assert . isAbove (
484
+ call . endStep ,
485
+ call . beginStep ,
486
+ "beginStep should precede endStep for non-instant calls"
487
+ ) ;
447
488
let inputs = Codec . Export . unsafeNativizeVariables ( byName ( call . arguments ) ) ;
448
489
assert . deepEqual ( inputs , {
449
490
x : 4
@@ -481,6 +522,7 @@ describe("Transaction log (visualizer)", function () {
481
522
verifyNoIntermediates ( untied ) ;
482
523
483
524
const root = bugger . view ( txlog . views . transactionLog ) ;
525
+ const steps = bugger . view ( trace . steps ) . length ;
484
526
assert . equal ( root . type , "transaction" ) ;
485
527
assert . lengthOf ( root . actions , 1 ) ;
486
528
let call = root . actions [ 0 ] ;
@@ -492,13 +534,16 @@ describe("Transaction log (visualizer)", function () {
492
534
assert . equal ( call . returnKind , "unwind" ) ;
493
535
assert . lengthOf ( call . arguments , 0 ) ;
494
536
assert . lengthOf ( call . actions , 1 ) ;
537
+ assert . equal ( call . beginStep , - 1 ) ; //initial call considered to begin on step -1
538
+ assert . equal ( call . endStep , steps - 1 ) ;
495
539
call = call . actions [ 0 ] ;
496
540
assert . equal ( call . type , "callinternal" ) ;
497
541
assert . equal ( call . functionName , "callReverter" ) ;
498
542
assert . equal ( call . contractName , "VizTest" ) ;
499
543
assert . equal ( call . returnKind , "revert" ) ;
500
544
assert . lengthOf ( call . arguments , 0 ) ;
501
545
assert . equal ( call . error . kind , "revert" ) ;
546
+ assert . equal ( call . endStep , steps - 1 ) ; //the internal and external call should end simultaneously
502
547
assert . lengthOf ( call . error . arguments , 1 ) ;
503
548
assert . equal (
504
549
Codec . Export . unsafeNativize ( call . error . arguments [ 0 ] . value ) ,
@@ -536,7 +581,9 @@ describe("Transaction log (visualizer)", function () {
536
581
x : 108
537
582
} ) ;
538
583
assert . notProperty ( call , "returnValues" ) ;
584
+ assert . notProperty ( call , "endStep" ) ;
539
585
assert . lengthOf ( call . actions , 0 ) ;
586
+ assert . equal ( call . beginStep , - 1 ) ;
540
587
assert . isTrue ( call . waitingForFunctionDefinition ) ;
541
588
assert . isTrue ( call . absorbNextInternalCall ) ;
542
589
} ) ;
@@ -708,6 +755,18 @@ describe("Transaction log (visualizer)", function () {
708
755
assert . strictEqual ( event . address , instance . address ) ;
709
756
assert . strictEqual ( event . codeAddress , instance . address ) ;
710
757
assert . isTrue ( event . status ) ;
758
+
759
+ //now: check that they all have steps and are in increasing order
760
+ let previousStep = - 1 ;
761
+ for ( const event of flattedEvents ) {
762
+ assert . isFinite ( event . step ) ;
763
+ assert . isAbove (
764
+ event . step ,
765
+ previousStep ,
766
+ "steps should be in increasing order"
767
+ ) ;
768
+ previousStep = event . step ;
769
+ }
711
770
} ) ;
712
771
713
772
it ( "Correctly logs an event inside a library" , async function ( ) {
0 commit comments