@@ -13,9 +13,12 @@ describe('getWarpRouteAmountParts', () => {
1313 expect ( result ) . toEqual ( { amount : 10n ** 18n , decimals : 18 } ) ;
1414 } ) ;
1515
16- it ( 'throws for non-integer scale (normalizeScale rejects it) ' , ( ) => {
16+ it ( 'falls back to scale=1 for non-integer scale' , ( ) => {
1717 const messageAmount = 1_000_000n ;
18- expect ( ( ) => getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : 1.5 } ) ) . toThrow ( ) ;
18+ expect ( getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : 1.5 } ) ) . toEqual ( {
19+ amount : 1_000_000n ,
20+ decimals : 6 ,
21+ } ) ;
1922 } ) ;
2023
2124 it ( 'handles numeric scale values' , ( ) => {
@@ -59,14 +62,20 @@ describe('getWarpRouteAmountParts', () => {
5962 expect ( result ) . toEqual ( { amount : 10n ** 18n , decimals : 18 } ) ;
6063 } ) ;
6164
62- it ( 'handles zero scale (division by zero throws) ' , ( ) => {
65+ it ( 'falls back to scale=1 for zero scale ' , ( ) => {
6366 const messageAmount = 1_000_000n ;
64- expect ( ( ) => getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : 0 } ) ) . toThrow ( ) ;
67+ expect ( getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : 0 } ) ) . toEqual ( {
68+ amount : 1_000_000n ,
69+ decimals : 6 ,
70+ } ) ;
6571 } ) ;
6672
67- it ( 'handles negative scale (assertValidScale throws) ' , ( ) => {
73+ it ( 'falls back to scale=1 for negative scale ' , ( ) => {
6874 const messageAmount = 1_000_000n ;
69- expect ( ( ) => getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : - 10 } ) ) . toThrow ( ) ;
75+ expect ( getWarpRouteAmountParts ( messageAmount , { decimals : 6 , scale : - 10 } ) ) . toEqual ( {
76+ amount : 1_000_000n ,
77+ decimals : 6 ,
78+ } ) ;
7079 } ) ;
7180
7281 it ( 'handles invalid rational scales as invalid (falls back to 1)' , ( ) => {
0 commit comments