@@ -30,6 +30,8 @@ contract VizTest is Nothing {
30
30
event TakesArgs(uint indexed x, uint y);
31
31
event Confusing(uint a, bytes32 indexed b, uint c);
32
32
33
+ Tertiary tert;
34
+
33
35
function testCall(uint x) public returns (uint y) {
34
36
return called(x);
35
37
}
@@ -70,7 +72,16 @@ contract VizTest is Nothing {
70
72
VizLibrary.confuse();
71
73
}
72
74
73
- constructor() payable {
75
+ constructor(Tertiary _tert) payable {
76
+ tert = _tert;
77
+ }
78
+
79
+ function testFlatEvents() public {
80
+ testCall(1);
81
+ try tert.noisyFail() {
82
+ } catch (bytes memory) {
83
+ }
84
+ testCall(1);
74
85
}
75
86
}
76
87
@@ -97,6 +108,17 @@ contract Secondary {
97
108
}
98
109
}
99
110
111
+ contract Tertiary {
112
+
113
+ event Tert();
114
+
115
+ function noisyFail() public {
116
+ emit Tert();
117
+ VizLibrary.loudIncrement(1);
118
+ revert();
119
+ }
120
+ }
121
+
100
122
library VizLibrary {
101
123
event Noise();
102
124
event Confusing(uint x, bytes32 y, uint indexed z);
@@ -117,13 +139,17 @@ let sources = {
117
139
} ;
118
140
119
141
const __MIGRATION = `
120
- let VizTest = artifacts.require("VizTest");
121
- let VizLibrary = artifacts.require("VizLibrary");
122
-
123
- module.exports = function(deployer) {
124
- deployer.deploy(VizLibrary);
125
- deployer.link(VizLibrary, VizTest);
126
- deployer.deploy(VizTest, { value: 100 });
142
+ const VizTest = artifacts.require("VizTest");
143
+ const VizLibrary = artifacts.require("VizLibrary");
144
+ const Tertiary = artifacts.require("Tertiary");
145
+
146
+ module.exports = async function(deployer) {
147
+ await deployer.deploy(VizLibrary);
148
+ await deployer.link(VizLibrary, Tertiary);
149
+ await deployer.deploy(Tertiary);
150
+ const tert = await Tertiary.deployed();
151
+ await deployer.link(VizLibrary, VizTest);
152
+ await deployer.deploy(VizTest, tert.address, { value: 100 });
127
153
};
128
154
` ;
129
155
@@ -624,6 +650,49 @@ describe("Transaction log (visualizer)", function () {
624
650
) ; //683 in hex
625
651
} ) ;
626
652
653
+ it ( "Correctly flattens events" , async function ( ) {
654
+ this . timeout ( 12000 ) ;
655
+ const instance = await abstractions . VizTest . deployed ( ) ;
656
+ const tertInstance = await abstractions . Tertiary . deployed ( ) ;
657
+ const libInstance = await abstractions . VizLibrary . deployed ( ) ;
658
+ const receipt = await instance . testFlatEvents ( ) ;
659
+ const txHash = receipt . tx ;
660
+
661
+ const bugger = await Debugger . forTx ( txHash , {
662
+ provider,
663
+ compilations
664
+ } ) ;
665
+
666
+ await bugger . runToEnd ( ) ;
667
+
668
+ const flattedEvents = bugger . view ( txlog . views . flattedEvents ) ;
669
+ assert . lengthOf ( flattedEvents , 4 ) ;
670
+ //event #0: Dummy()
671
+ let event = flattedEvents [ 0 ] ;
672
+ assert . strictEqual ( event . decoding . abi . name , "Dummy" ) ;
673
+ assert . strictEqual ( event . address , instance . address ) ;
674
+ assert . strictEqual ( event . codeAddress , instance . address ) ;
675
+ assert . isTrue ( event . status ) ;
676
+ //event #1: Tert()
677
+ event = flattedEvents [ 1 ] ;
678
+ assert . strictEqual ( event . decoding . abi . name , "Tert" ) ;
679
+ assert . strictEqual ( event . address , tertInstance . address ) ;
680
+ assert . strictEqual ( event . codeAddress , tertInstance . address ) ;
681
+ assert . isFalse ( event . status ) ;
682
+ //event #2: Noise()
683
+ event = flattedEvents [ 2 ] ;
684
+ assert . strictEqual ( event . decoding . abi . name , "Noise" ) ;
685
+ assert . strictEqual ( event . address , tertInstance . address ) ;
686
+ assert . strictEqual ( event . codeAddress , libInstance . address ) ;
687
+ assert . isFalse ( event . status ) ;
688
+ //event #3: Dummy()
689
+ event = flattedEvents [ 3 ] ;
690
+ assert . strictEqual ( event . decoding . abi . name , "Dummy" ) ;
691
+ assert . strictEqual ( event . address , instance . address ) ;
692
+ assert . strictEqual ( event . codeAddress , instance . address ) ;
693
+ assert . isTrue ( event . status ) ;
694
+ } ) ;
695
+
627
696
it ( "Correctly logs an event inside a library" , async function ( ) {
628
697
this . timeout ( 12000 ) ;
629
698
const instance = await abstractions . VizTest . deployed ( ) ;
0 commit comments