@@ -20,6 +20,8 @@ import (
2020 network_debug_contract "github.com/smartcontractkit/chainlink-testing-framework/seth/contracts/bind/debug"
2121 link_token "github.com/smartcontractkit/chainlink-testing-framework/seth/contracts/bind/link"
2222 "github.com/smartcontractkit/chainlink-testing-framework/seth/contracts/bind/link_token_interface"
23+ "github.com/smartcontractkit/chainlink-testing-framework/seth/contracts/bind/unique_event_one"
24+ "github.com/smartcontractkit/chainlink-testing-framework/seth/contracts/bind/unique_event_two"
2325 "github.com/smartcontractkit/chainlink-testing-framework/seth/test_utils"
2426)
2527
@@ -1786,6 +1788,79 @@ func TestTraceVariousCallTypesAndNestingLevels(t *testing.T) {
17861788 require .Equal (t , 4 , c .Tracer .GetDecodedCalls (decodedTx .Hash )[8 ].NestingLevel , "expected nesting level to be 4" )
17871789}
17881790
1791+ func TestNestedEvents (t * testing.T ) {
1792+ c := newClientWithContractMapFromEnv (t )
1793+ SkipAnvil (t , c )
1794+
1795+ tx , txErr := TestEnv .DebugContract .TraceNestedEvents (c .NewTXOpts ())
1796+ require .NoError (t , txErr , "transaction should have succeeded" )
1797+ decoded , decodeErr := c .Decode (tx , txErr )
1798+ require .NoError (t , decodeErr , "transaction should have succeeded" )
1799+
1800+ expectedLogs := []seth.DecodedCommonLog {
1801+ {
1802+ Signature : "UniqueSubDebugEvent()" ,
1803+ Address : TestEnv .DebugSubContractAddress ,
1804+ EventData : map [string ]interface {}{},
1805+ Topics : []string {"0xe0b03c5e88196d907268b0babc690e041bdc7fcc1abf4bbf1e363e28c17e6b9b" },
1806+ },
1807+ {
1808+ Signature : "UniqueDebugEvent()" ,
1809+ Address : TestEnv .DebugContractAddress ,
1810+ EventData : map [string ]interface {}{},
1811+ Topics : []string {"0xa0f7c7c1fff15178b5db3e56860767f0889c56b591bd2d9ba3121b491347d74c" },
1812+ },
1813+ }
1814+
1815+ require .Equal (t , 2 , len (decoded .Events ), "expected 2 events" )
1816+ var actualEvents []seth.DecodedCommonLog
1817+ for _ , event := range decoded .Events {
1818+ actualEvents = append (actualEvents , event .DecodedCommonLog )
1819+ }
1820+
1821+ require .EqualValues (t , expectedLogs , actualEvents , "decoded events do not match" )
1822+ }
1823+
1824+ func TestSameEventTwoABIs (t * testing.T ) {
1825+ c := newClientWithContractMapFromEnv (t )
1826+ SkipAnvil (t , c )
1827+
1828+ contractAbi , err := unique_event_one .UniqueEventOneMetaData .GetAbi ()
1829+ require .NoError (t , err , "failed to get contract ABI" )
1830+ oneData , err := c .DeployContract (c .NewTXOpts (), "TestContractOne" , * contractAbi , common .FromHex (unique_event_one .UniqueEventOneMetaData .Bin ))
1831+ require .NoError (t , err , "failed to deploy contract" )
1832+
1833+ contractAbi , err = unique_event_two .UniqueEventTwoMetaData .GetAbi ()
1834+ require .NoError (t , err , "failed to get contract ABI" )
1835+ _ , err = c .DeployContract (c .NewTXOpts (), "TestContractTwo" , * contractAbi , common .FromHex (unique_event_two .UniqueEventTwoMetaData .Bin ))
1836+ require .NoError (t , err , "failed to deploy contract" )
1837+
1838+ oneInstance , err := unique_event_one .NewUniqueEventOne (oneData .Address , c .Client )
1839+ require .NoError (t , err , "failed to create contract instance" )
1840+ decoded , txErr := c .Decode (oneInstance .ExecuteFirstOperation (c .NewTXOpts (), big .NewInt (1 ), big .NewInt (2 )))
1841+ require .NoError (t , txErr , "transaction should have succeeded" )
1842+
1843+ expectedLogs := []seth.DecodedCommonLog {
1844+ {
1845+ Signature : "NonUniqueEvent(int256,int256)" ,
1846+ Address : oneData .Address ,
1847+ EventData : map [string ]interface {}{
1848+ "a" : big .NewInt (1 ),
1849+ "b" : big .NewInt (2 ),
1850+ },
1851+ Topics : []string {"0x192aedde7837c0cbfb2275e082ba2391de36cf5a893681e9dac2cced6947614e" , "0x0000000000000000000000000000000000000000000000000000000000000001" , "0x0000000000000000000000000000000000000000000000000000000000000002" },
1852+ },
1853+ }
1854+
1855+ require .Equal (t , 1 , len (decoded .Events ), "expected 1 event" )
1856+ var actualEvents []seth.DecodedCommonLog
1857+ for _ , event := range decoded .Events {
1858+ actualEvents = append (actualEvents , event .DecodedCommonLog )
1859+ }
1860+
1861+ require .EqualValues (t , expectedLogs , actualEvents , "decoded events do not match" )
1862+ }
1863+
17891864func removeGasDataFromDecodedCalls (decodedCall map [string ][]* seth.DecodedCall ) {
17901865 for _ , decodedCalls := range decodedCall {
17911866 for _ , call := range decodedCalls {
0 commit comments