@@ -2,6 +2,7 @@ import * as should from 'should';
22
33import { TestBitGo , TestBitGoAPI } from '@bitgo/sdk-test' ;
44import { BitGoAPI } from '@bitgo/sdk-api' ;
5+ import { coins } from '@bitgo/statics' ;
56
67import { Flr , Tflr } from '../../src/index' ;
78import { ExplainTransactionOptions } from '../../src/iface' ;
@@ -606,9 +607,10 @@ describe('flr', function () {
606607 const hopDestinationAddress =
607608 'P-costwo15msvr27szvhhpmah0c38gcml7vm29xjh7tcek8~P-costwo1cwrdtrgf4xh80ncu7palrjw7gn4mpj0n4dxghh~P-costwo1zt9n96hey4fsvnde35n3k4kt5pu7c784dzewzd' ;
608609 const hopAddress = '0x28A05933dC76e4e6c25f35D5c9b2A58769700E76' ;
609- const importTxFee = 200000 ; // Match FlarePTestnet txFee from networks.ts
610- // Adjusted amount to work backwards from hop amount (50000000): 50000000 - 200000 = 49800000 nanoFLR
611- const amount = 49800000000000000 ;
610+ const flrpCoin = coins . get ( 'tflrp' ) ;
611+ const importTxFee = Number ( ( flrpCoin . network as any ) . minImportToPFee ) ;
612+ // Adjusted amount to work backwards from hop amount (50000000): 50000000 - importTxFee nanoFLR
613+ const amount = ( 50000000 - importTxFee ) * 1e9 ;
612614 const txParams = {
613615 recipients : [ { amount, address : hopDestinationAddress } ] ,
614616 wallet : wallet ,
@@ -675,9 +677,7 @@ describe('flr', function () {
675677 await tflrCoin
676678 . verifyTransaction ( verifyFlrTransactionOptions )
677679 . should . be . rejectedWith (
678- `Hop amount: ${ amount / 1e9 + importTxFee } does not equal original amount: ${
679- amount / 1e9 + importTxFee + 1
680- } `
680+ `Hop amount: ${ amount / 1e9 + importTxFee } is less than required amount: ${ amount / 1e9 + importTxFee + 1 } `
681681 ) ;
682682 } ) ;
683683
@@ -802,11 +802,13 @@ describe('flr', function () {
802802
803803 await ( tflrCoin as any )
804804 . validateHopPrebuild ( wallet , hopPrebuild , originalParams )
805- . should . be . rejectedWith ( / H o p a m o u n t : .* d o e s n o t e q u a l o r i g i n a l a m o u n t / ) ;
805+ . should . be . rejectedWith ( / H o p a m o u n t : .* i s l e s s t h a n r e q u i r e d a m o u n t / ) ;
806806 } ) ;
807807
808808 it ( 'should throw error for Export hop prebuild with mismatched destination' , async function ( ) {
809809 const wallet = new Wallet ( bitgo , tflrCoin , { } ) ;
810+ const flrpCoin = coins . get ( 'tflrp' ) ;
811+ const minImportToPFee = Number ( ( flrpCoin . network as any ) . minImportToPFee ) ;
810812 const hopPrebuild = {
811813 tx : hopExportTx ,
812814 id : hopExportTxId ,
@@ -826,7 +828,7 @@ describe('flr', function () {
826828 recipients : [
827829 {
828830 address : 'P-costwo1different~P-costwo1address~P-costwo1here' ,
829- amount : '49800000000000000' , // 50000000 - 200000 (txFee) = 49800000 nanoFLR = 49800000000000000 wei
831+ amount : String ( ( 50000000 - minImportToPFee ) * 1e9 ) , // Correct amount so destination check is reached
830832 } ,
831833 ] ,
832834 } ;
0 commit comments