@@ -1872,7 +1872,7 @@ test("Can reserve exact amount needed for offer (Test, CI)", async () => {
18721872 } ) ;
18731873} ) ;
18741874
1875- test ( "Cannot post offer outside of trade limits (Test, CI, sanity check)" , async ( ) => {
1875+ test ( "Cannot make or take offer outside of limits (Test, CI, sanity check)" , async ( ) => {
18761876 let assetCode = "USD" ;
18771877 const account = await createPaymentAccount ( user1 , assetCode , "zelle" ) ;
18781878 const diff = 10000000000n ;
@@ -1888,7 +1888,7 @@ test("Cannot post offer outside of trade limits (Test, CI, sanity check)", async
18881888 } ) ;
18891889 throw new Error ( "Should have rejected posting offer above trade limit" )
18901890 } catch ( err : any ) {
1891- if ( err . message . indexOf ( "Amount is larger than " ) < 0 ) throw err ;
1891+ if ( err . message . indexOf ( "must be below maximum " ) < 0 ) throw err ;
18921892 }
18931893
18941894 // test posting sell offer above limit
@@ -1902,7 +1902,7 @@ test("Cannot post offer outside of trade limits (Test, CI, sanity check)", async
19021902 } ) ;
19031903 throw new Error ( "Should have rejected posting offer above trade limit" )
19041904 } catch ( err : any ) {
1905- if ( err . message . indexOf ( "Amount is larger than " ) < 0 ) throw err ;
1905+ if ( err . message . indexOf ( "must be below maximum " ) < 0 ) throw err ;
19061906 }
19071907
19081908 // test posting sell offer below limit
@@ -1988,12 +1988,27 @@ test("Cannot post offer outside of trade limits (Test, CI, sanity check)", async
19881988 // test that sell limit is higher than buy limit
19891989 offerId = await executeTrade ( {
19901990 offerAmount : HavenoUtils . xmrToAtomicUnits ( 2.1 ) ,
1991+ offerMinAmount : TestConfig . minAmount ,
19911992 direction : OfferDirection . SELL ,
19921993 assetCode : assetCode ,
19931994 makerPaymentAccountId : account . getId ( ) ,
19941995 takeOffer : false
19951996 } ) ;
19961997 await user1 . removeOffer ( offerId ) ;
1998+
1999+ // cannot take offer outside of range
2000+ try {
2001+ await executeTrade ( {
2002+ offerAmount : HavenoUtils . xmrToAtomicUnits ( 2.1 ) ,
2003+ offerMinAmount : TestConfig . minAmount ,
2004+ tradeAmount : HavenoUtils . xmrToAtomicUnits ( 2.2 ) ,
2005+ direction : OfferDirection . SELL ,
2006+ assetCode : assetCode ,
2007+ makerPaymentAccountId : account . getId ( ) ,
2008+ } ) ;
2009+ } catch ( err : any ) {
2010+ if ( err . message . indexOf ( "Trade amount exceeds offer amount" ) < 0 ) throw err ;
2011+ }
19972012} ) ;
19982013
19992014test ( "Can complete a trade within a range and without a buyer deposit (Test, CI)" , async ( ) => {
@@ -2284,7 +2299,7 @@ test("Cannot make or take offer with insufficient funds (Test, CI, sanity check)
22842299 user3 = await initHaveno ( ) ;
22852300
22862301 // user3 creates payment account
2287- const paymentAccount = await createPaymentAccount ( user3 , TestConfig . trade . assetCode ! ) ;
2302+ let paymentAccount = await createPaymentAccount ( user3 , TestConfig . trade . assetCode ! ) ;
22882303
22892304 // user3 cannot make offer with insufficient funds
22902305 try {
@@ -2317,6 +2332,7 @@ test("Cannot make or take offer with insufficient funds (Test, CI, sanity check)
23172332 if ( ! getOffer ( await user3 . getOffers ( offer . getCounterCurrencyCode ( ) ) , offer . getId ( ) ) ) throw new Error ( "Offer " + offer . getId ( ) + " was not found in user3's offers" ) ;
23182333
23192334 // user3 cannot take offer with insufficient funds
2335+ paymentAccount = await createPaymentAccount ( user3 , offer . getCounterCurrencyCode ( ) , offer . getPaymentMethodId ( ) ) ;
23202336 try {
23212337 await user3 . takeOffer ( offer . getId ( ) , paymentAccount . getId ( ) ) ;
23222338 throw new Error ( "Should have failed taking offer with insufficient funds" )
0 commit comments