@@ -136,16 +136,16 @@ describe('IOTA:', function () {
136136 } ) ;
137137
138138 describe ( 'explainTransaction' , ( ) => {
139- it ( 'should throw error for missing txBase64 ' , async function ( ) {
139+ it ( 'should throw error for missing txHex ' , async function ( ) {
140140 await assert . rejects (
141- async ( ) => await basecoin . explainTransaction ( { txBase64 : '' } ) ,
142- / m i s s i n g r e q u i r e d t x p r e b u i l d p r o p e r t y t x B a s e 6 4 /
141+ async ( ) => await basecoin . explainTransaction ( { txHex : '' } ) ,
142+ / m i s s i n g r e q u i r e d t x p r e b u i l d p r o p e r t y t x H e x /
143143 ) ;
144144 } ) ;
145145
146146 it ( 'should throw error for invalid transaction' , async function ( ) {
147147 await assert . rejects (
148- async ( ) => await basecoin . explainTransaction ( { txBase64 : 'invalidTxBase64 ' } ) ,
148+ async ( ) => await basecoin . explainTransaction ( { txHex : 'invalidTxHex ' } ) ,
149149 / F a i l e d t o r e b u i l d t r a n s a c t i o n /
150150 ) ;
151151 } ) ;
@@ -171,14 +171,14 @@ describe('IOTA:', function () {
171171 } ) ;
172172
173173 describe ( 'verifyTransaction' , ( ) => {
174- it ( 'should throw error for missing txBase64 ' , async function ( ) {
174+ it ( 'should throw error for missing txHex ' , async function ( ) {
175175 await assert . rejects (
176176 async ( ) =>
177177 await basecoin . verifyTransaction ( {
178178 txPrebuild : { } ,
179179 txParams : { recipients : testData . recipients } ,
180180 } ) ,
181- / m i s s i n g r e q u i r e d t x p r e b u i l d p r o p e r t y t x B a s e 6 4 /
181+ / m i s s i n g r e q u i r e d t x p r e b u i l d p r o p e r t y t x H e x /
182182 ) ;
183183 } ) ;
184184
@@ -191,16 +191,14 @@ describe('IOTA:', function () {
191191 txBuilder . gasData ( testData . gasData ) ;
192192
193193 const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
194- const txJson = tx . toJson ( ) ;
195-
196- // Rebuild from JSON to simulate what would happen in verification
197- const rebuiltTxBuilder = factory . getTransferBuilder ( ) ;
198- ( rebuiltTxBuilder . transaction as TransferTransaction ) . parseFromJSON ( txJson ) ;
199- const rebuiltTx = ( await rebuiltTxBuilder . build ( ) ) as TransferTransaction ;
200-
201- // Verify the rebuilt transaction matches
202- should . equal ( rebuiltTx . sender , testData . sender . address ) ;
203- should . deepEqual ( rebuiltTx . recipients , testData . recipients ) ;
194+ const txHex = Buffer . from ( await tx . toBroadcastFormat ( ) , 'base64' ) . toString ( 'hex' ) ;
195+ should . equal (
196+ await basecoin . verifyTransaction ( {
197+ txPrebuild : { txHex : txHex } ,
198+ txParams : { recipients : testData . recipients } ,
199+ } ) ,
200+ true
201+ ) ;
204202 } ) ;
205203
206204 it ( 'should detect mismatched recipients' , async function ( ) {
@@ -211,12 +209,15 @@ describe('IOTA:', function () {
211209 txBuilder . gasData ( testData . gasData ) ;
212210
213211 const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
214- const txJson = tx . toJson ( ) ;
215-
216- const differentRecipients = [ { address : testData . addresses . validAddresses [ 0 ] , amount : '9999' } ] ;
217-
218- // Recipients don't match
219- should . notDeepEqual ( txJson . recipients , differentRecipients ) ;
212+ const txHex = Buffer . from ( await tx . toBroadcastFormat ( ) , 'base64' ) . toString ( 'hex' ) ;
213+ assert . rejects (
214+ async ( ) =>
215+ await basecoin . verifyTransaction ( {
216+ txPrebuild : { txHex : txHex } ,
217+ txParams : { recipients : testData . recipients } ,
218+ } ) ,
219+ / T x r e c i p i e n t s d o e s n o t m a t c h w i t h e x p e c t e d t x P a r a m s r e c i p i e n t s /
220+ ) ;
220221 } ) ;
221222
222223 it ( 'should verify transaction without recipients parameter' , async function ( ) {
@@ -227,17 +228,22 @@ describe('IOTA:', function () {
227228 txBuilder . gasData ( testData . gasData ) ;
228229
229230 const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
230-
231- // Verification should still work even if no recipients are provided for comparison
232- should . exist ( tx ) ;
233- should . equal ( tx . type , TransactionType . Send ) ;
231+ const txHex = Buffer . from ( await tx . toBroadcastFormat ( ) , 'base64' ) . toString ( 'hex' ) ;
232+
233+ should . equal (
234+ await basecoin . verifyTransaction ( {
235+ txPrebuild : { txHex : txHex } ,
236+ txParams : { } ,
237+ } ) ,
238+ true
239+ ) ;
234240 } ) ;
235241 } ) ;
236242
237243 describe ( 'parseTransaction' , ( ) => {
238244 it ( 'should throw error for invalid transaction' , async function ( ) {
239245 await assert . rejects (
240- async ( ) => await basecoin . parseTransaction ( { txBase64 : 'invalidTxBase64 ' } ) ,
246+ async ( ) => await basecoin . parseTransaction ( { txHex : 'invalidTxHex ' } ) ,
241247 / F a i l e d t o r e b u i l d t r a n s a c t i o n /
242248 ) ;
243249 } ) ;
0 commit comments