@@ -234,9 +234,10 @@ describe("PegInContract registerPegIn function should", () => {
234234 ) ;
235235 } ) ;
236236
237- it ( "refund user when call was not done and user under paid the quote" , async ( ) => {
238- const { contract, fullLp, signers, bridgeMock, collateralManagement } =
239- await loadFixture ( deployPegInContractFixture ) ;
237+ it ( "revert when user under paid the quote" , async ( ) => {
238+ const { contract, fullLp, signers, bridgeMock } = await loadFixture (
239+ deployPegInContractFixture
240+ ) ;
240241 const lbcAddress = await contract . getAddress ( ) ;
241242 const user = signers [ 0 ] ;
242243
@@ -259,6 +260,12 @@ describe("PegInContract registerPegIn function should", () => {
259260 nConfirmationSeconds : 600 ,
260261 } ) ;
261262
263+ const QuotesLib = new ethers . Contract (
264+ ethers . ZeroAddress ,
265+ Quotes__factory . abi ,
266+ ethers . provider
267+ ) ;
268+
262269 const height = PEGIN_CONSTANTS . HEIGHT_MOCK ;
263270 const peginAmount = totalValue ( quote ) - ethers . parseEther ( "0.0001" ) ;
264271 await bridgeMock . setPegin ( quoteHash , { value : peginAmount } ) ;
@@ -268,32 +275,22 @@ describe("PegInContract registerPegIn function should", () => {
268275 nConfirmationHeader
269276 ) ;
270277
271- const tx = contract
272- . connect ( fullLp )
273- . registerPegIn (
274- quote ,
275- signature ,
276- PEGIN_CONSTANTS . RAW_TRANSACTION_MOCK ,
277- PEGIN_CONSTANTS . PMT_MOCK ,
278- height
279- ) ;
280- await expect ( tx )
281- . to . emit ( contract , "PegInRegistered" )
282- . withArgs ( quoteHash , peginAmount ) ;
283- await expect ( tx ) . not . to . emit ( collateralManagement , "Penalized" ) ;
284- await expect ( tx )
285- . to . emit ( contract , "Refund" )
286- . withArgs ( user . address , quoteHash , peginAmount , true ) ;
287- await expect ( tx ) . not . to . emit ( contract , "CallForUser" ) ;
288- await expect ( tx ) . not . to . emit ( contract , "BridgeCapExceeded" ) ;
289- await expect ( tx ) . not . to . emit ( contract , "DaoContribution" ) ;
278+ await expect (
279+ contract
280+ . connect ( fullLp )
281+ . registerPegIn (
282+ quote ,
283+ signature ,
284+ PEGIN_CONSTANTS . RAW_TRANSACTION_MOCK ,
285+ PEGIN_CONSTANTS . PMT_MOCK ,
286+ height
287+ )
288+ )
289+ . to . be . revertedWithCustomError ( QuotesLib , "AmountTooLow" )
290+ . withArgs ( peginAmount , totalValue ( quote ) ) ;
290291 await expect ( contract . getCurrentContribution ( ) ) . to . eventually . eq ( 0n ) ;
291292 await expect ( contract . getQuoteStatus ( quoteHash ) ) . to . eventually . eq (
292- PegInStates . PROCESSED_QUOTE
293- ) ;
294- await expect ( tx ) . to . changeEtherBalances (
295- [ user , fullLp , contract ] ,
296- [ peginAmount , 0n , 0n ]
293+ PegInStates . UNPROCESSED_QUOTE
297294 ) ;
298295 await expect ( contract . getBalance ( fullLp ) ) . to . eventually . eq ( 0n ) ;
299296 } ) ;
@@ -821,7 +818,6 @@ describe("PegInContract registerPegIn function should", () => {
821818 height + Number ( quote . depositConfirmations ) - 1 ,
822819 nConfirmationHeader
823820 ) ;
824- const minValue = totalValue ( quote ) - totalValue ( quote ) / 10_000n ;
825821 await expect (
826822 contract
827823 . connect ( fullLp )
@@ -834,7 +830,7 @@ describe("PegInContract registerPegIn function should", () => {
834830 )
835831 )
836832 . to . be . revertedWithCustomError ( QuotesLib , "AmountTooLow" )
837- . withArgs ( peginAmount , minValue ) ;
833+ . withArgs ( peginAmount , totalValue ( quote ) ) ;
838834 await expect ( contract . getCurrentContribution ( ) ) . to . eventually . eq ( 0n ) ;
839835 await expect ( contract . getQuoteStatus ( quoteHash ) ) . to . eventually . eq (
840836 PegInStates . UNPROCESSED_QUOTE
0 commit comments