Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 873542b

Browse files
committed
Add test of flattedEvents selector
1 parent b4b5a9d commit 873542b

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

packages/debugger/test/txlog.js

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ contract VizTest is Nothing {
3030
event TakesArgs(uint indexed x, uint y);
3131
event Confusing(uint a, bytes32 indexed b, uint c);
3232
33+
Tertiary tert;
34+
3335
function testCall(uint x) public returns (uint y) {
3436
return called(x);
3537
}
@@ -70,7 +72,16 @@ contract VizTest is Nothing {
7072
VizLibrary.confuse();
7173
}
7274
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);
7485
}
7586
}
7687
@@ -97,6 +108,17 @@ contract Secondary {
97108
}
98109
}
99110
111+
contract Tertiary {
112+
113+
event Tert();
114+
115+
function noisyFail() public {
116+
emit Tert();
117+
VizLibrary.loudIncrement(1);
118+
revert();
119+
}
120+
}
121+
100122
library VizLibrary {
101123
event Noise();
102124
event Confusing(uint x, bytes32 y, uint indexed z);
@@ -117,13 +139,17 @@ let sources = {
117139
};
118140

119141
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 });
127153
};
128154
`;
129155

@@ -624,6 +650,49 @@ describe("Transaction log (visualizer)", function () {
624650
); //683 in hex
625651
});
626652

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+
627696
it("Correctly logs an event inside a library", async function () {
628697
this.timeout(12000);
629698
const instance = await abstractions.VizTest.deployed();

0 commit comments

Comments
 (0)