@@ -63,4 +63,89 @@ describe("test delegation transactions outcome parser", () => {
6363 assert . lengthOf ( outcome , 1 ) ;
6464 assert . equal ( outcome [ 0 ] . contractAddress , contractAddress . toBech32 ( ) ) ;
6565 } ) ;
66+
67+ it ( "should test parseClaimRewards " , ( ) => {
68+ const encodedTopics = [ "AvYUMPsrWw==" , "ZmFsc2U=" , "AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAABD///8=" ] ;
69+
70+ const claimRewardsEvent = new TransactionEvent ( {
71+ address : new Address ( "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2" ) ,
72+ identifier : "claimRewards" ,
73+ topics : b64TopicsToBytes ( encodedTopics ) ,
74+ } ) ;
75+
76+ const logs = new TransactionLogs ( { events : [ claimRewardsEvent ] } ) ;
77+
78+ const transaction = new TransactionOnNetwork ( { logs : logs } ) ;
79+
80+ const outcome = parser . parseClaimRewards ( transaction ) ;
81+
82+ assert . lengthOf ( outcome , 1 ) ;
83+ assert . equal ( outcome [ 0 ] . amount , 833516534967131n ) ;
84+ } ) ;
85+
86+ it ( "should test parseDelegate " , ( ) => {
87+ const encodedTopics = [
88+ "DeC2s6dkAAA=" ,
89+ "DeC2s6dkAAA=" ,
90+ "pg==" ,
91+ "Gasl6c5mNE7QJw==" ,
92+ "AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAABn///8=" ,
93+ ] ;
94+
95+ const delegateEvent = new TransactionEvent ( {
96+ address : new Address ( "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2" ) ,
97+ identifier : "delegate" ,
98+ topics : b64TopicsToBytes ( encodedTopics ) ,
99+ } ) ;
100+
101+ const logs = new TransactionLogs ( { events : [ delegateEvent ] } ) ;
102+ const transaction = new TransactionOnNetwork ( { logs : logs } ) ;
103+
104+ const outcome = parser . parseDelegate ( transaction ) ;
105+
106+ assert . lengthOf ( outcome , 1 ) ;
107+ assert . equal ( outcome [ 0 ] . amount , 1000000000000000000n ) ;
108+ } ) ;
109+
110+ it ( "should test parseUndelegate " , ( ) => {
111+ const encodedTopics = [ "DeC2s6dkAAA=" , "DeC2s6dkAAA=" , "" , "irzOS6k1Z2fS" , "ZnVuZA4=" ] ;
112+
113+ const undelegateEvent = new TransactionEvent ( {
114+ address : new Address ( "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2" ) ,
115+ identifier : "unDelegate" ,
116+ topics : b64TopicsToBytes ( encodedTopics ) ,
117+ } ) ;
118+
119+ const logs = new TransactionLogs ( { events : [ undelegateEvent ] } ) ;
120+ const transaction = new TransactionOnNetwork ( { logs : logs } ) ;
121+
122+ const outcome = parser . parseUndelegate ( transaction ) ;
123+
124+ assert . lengthOf ( outcome , 1 ) ;
125+ assert . equal ( outcome [ 0 ] . amount , 1000000000000000000n ) ;
126+ } ) ;
127+
128+ it ( "should test parseRedelegateRewards " , ( ) => {
129+ const encodedTopics = [
130+ "BM+vfE0H7g==" ,
131+ "EVkZ9Arz3e4=" ,
132+ "Aw==" ,
133+ "iluVsi0Qb93u" ,
134+ "AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAC3///8=" ,
135+ ] ;
136+
137+ const redelegateRewardsEvent = new TransactionEvent ( {
138+ address : new Address ( "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2" ) ,
139+ identifier : "delegate" ,
140+ topics : b64TopicsToBytes ( encodedTopics ) ,
141+ } ) ;
142+
143+ const logs = new TransactionLogs ( { events : [ redelegateRewardsEvent ] } ) ;
144+ const transaction = new TransactionOnNetwork ( { logs : logs } ) ;
145+
146+ const outcome = parser . parseRedelegateRewards ( transaction ) ;
147+
148+ assert . lengthOf ( outcome , 1 ) ;
149+ assert . equal ( outcome [ 0 ] . amount , 1354252518492142n ) ;
150+ } ) ;
66151} ) ;
0 commit comments