@@ -179,6 +179,67 @@ describe('Hedera Hashgraph:', function () {
179179 explain . changeAmount . should . equal ( '0' ) ;
180180 } ) ;
181181
182+ it ( 'should explain an account update (staking) transaction' , async function ( ) {
183+ const sourceAccountId = '0.0.81320' ;
184+ const factory = getBuilderFactory ( 'thbar' ) ;
185+ const txBuilder = factory . getAccountUpdateBuilder ( ) ;
186+ txBuilder . fee ( { fee : '1000000000' } ) ;
187+ txBuilder . source ( { address : sourceAccountId } ) ;
188+ txBuilder . stakedNodeId ( 3 ) ;
189+ txBuilder . declineStakingReward ( false ) ;
190+ txBuilder . node ( { nodeId : '0.0.2345' } ) ;
191+ txBuilder . startTime ( '1596110493.372646570' ) ;
192+ const tx = await txBuilder . build ( ) ;
193+ const txHex = tx . toBroadcastFormat ( ) ;
194+
195+ const explain = await basecoin . explainTransaction ( {
196+ txHex,
197+ feeInfo : {
198+ size : 1000 ,
199+ fee : 1160407 ,
200+ feeRate : 1160407 ,
201+ } ,
202+ } ) ;
203+
204+ explain . id . should . equal ( sourceAccountId + '@1596110493.372646570' ) ;
205+ explain . outputAmount . should . equal ( '0' ) ;
206+ explain . timestamp . should . equal ( '1596110493.372646570' ) ;
207+ explain . outputs . length . should . equal ( 1 ) ;
208+ explain . outputs [ 0 ] . amount . should . equal ( '0' ) ;
209+ explain . outputs [ 0 ] . address . should . equal ( sourceAccountId ) ;
210+ explain . outputs [ 0 ] . memo . should . equal ( '' ) ;
211+ explain . fee . should . equal ( 1160407 ) ;
212+ explain . changeAmount . should . equal ( '0' ) ;
213+ } ) ;
214+
215+ it ( 'should explain an unstake (account update with nodeId -1) transaction' , async function ( ) {
216+ const sourceAccountId = '0.0.81320' ;
217+ const factory = getBuilderFactory ( 'thbar' ) ;
218+ const txBuilder = factory . getAccountUpdateBuilder ( ) ;
219+ txBuilder . fee ( { fee : '1000000000' } ) ;
220+ txBuilder . source ( { address : sourceAccountId } ) ;
221+ txBuilder . stakedNodeId ( - 1 ) ;
222+ txBuilder . node ( { nodeId : '0.0.2345' } ) ;
223+ txBuilder . startTime ( '1596110493.372646570' ) ;
224+ const tx = await txBuilder . build ( ) ;
225+ const txHex = tx . toBroadcastFormat ( ) ;
226+
227+ const explain = await basecoin . explainTransaction ( {
228+ txHex,
229+ feeInfo : {
230+ size : 1000 ,
231+ fee : 1160407 ,
232+ feeRate : 1160407 ,
233+ } ,
234+ } ) ;
235+
236+ explain . outputAmount . should . equal ( '0' ) ;
237+ explain . outputs . length . should . equal ( 1 ) ;
238+ explain . outputs [ 0 ] . amount . should . equal ( '0' ) ;
239+ explain . outputs [ 0 ] . address . should . equal ( sourceAccountId ) ;
240+ explain . fee . should . equal ( 1160407 ) ;
241+ } ) ;
242+
182243 it ( 'should verify isWalletAddress' , async function ( ) {
183244 const baseAddress = '0.0.41098' ;
184245 const validAddress1 = '0.0.41098?memoId=1' ;
0 commit comments