@@ -84,7 +84,9 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() {
8484 LiquidityPool : common .HexToAddress ("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
8585 Caller : common .HexToAddress ("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
8686 OrderHash : "orderHash" ,
87+ BorrowAmount : big .NewInt (1900000 ),
8788 }
89+
8890 s .mockCoordinator .EXPECT ().Execute (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil )
8991 s .mockTxFetcher .EXPECT ().GetTx (ad .OrderHash ).Return (& lighter.LighterTx {
9092 Type : lighter .TxTypeL2Transfer ,
@@ -125,6 +127,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
125127 LiquidityPool : common .HexToAddress ("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
126128 Caller : common .HexToAddress ("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
127129 OrderHash : "orderHash" ,
130+ BorrowAmount : big .NewInt (1900000 ),
128131 }
129132 s .mockTxFetcher .EXPECT ().GetTx (ad .OrderHash ).Return (& lighter.LighterTx {
130133 Type : lighter .TxTypeL2Withdraw ,
@@ -165,6 +168,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidAccount() {
165168 LiquidityPool : common .HexToAddress ("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
166169 Caller : common .HexToAddress ("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
167170 OrderHash : "orderHash" ,
171+ BorrowAmount : big .NewInt (1900000 ),
168172 }
169173 s .mockTxFetcher .EXPECT ().GetTx (ad .OrderHash ).Return (& lighter.LighterTx {
170174 Type : lighter .TxTypeL2Transfer ,
@@ -205,6 +209,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_MissingTx() {
205209 LiquidityPool : common .HexToAddress ("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
206210 Caller : common .HexToAddress ("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
207211 OrderHash : "orderHash" ,
212+ BorrowAmount : big .NewInt (1900000 ),
208213 }
209214 s .mockTxFetcher .EXPECT ().GetTx (ad .OrderHash ).Return (nil , fmt .Errorf ("not found" ))
210215
@@ -221,3 +226,45 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_MissingTx() {
221226 err = <- errChn
222227 s .NotNil (err )
223228}
229+
230+ func (s * LighterMessageHandlerTestSuite ) Test_HandleMessage_BorrowAmountTooHigh () {
231+ s .mockCommunication .EXPECT ().Broadcast (
232+ gomock .Any (),
233+ gomock .Any (),
234+ comm .LighterMsg ,
235+ "lighter" ,
236+ ).Return (nil )
237+ p , _ := pstoremem .NewPeerstore ()
238+ s .mockHost .EXPECT ().Peerstore ().Return (p )
239+
240+ errChn := make (chan error , 1 )
241+ ad := & message.LighterData {
242+ ErrChn : errChn ,
243+ Nonce : big .NewInt (101 ),
244+ LiquidityPool : common .HexToAddress ("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
245+ Caller : common .HexToAddress ("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657" ),
246+ OrderHash : "orderHash" ,
247+ BorrowAmount : big .NewInt (2000000 ),
248+ }
249+
250+ s .mockTxFetcher .EXPECT ().GetTx (ad .OrderHash ).Return (& lighter.LighterTx {
251+ Type : lighter .TxTypeL2Transfer ,
252+ Transfer : & lighter.Transfer {
253+ USDCAmount : 2000000 ,
254+ ToAccountIndex : 3 ,
255+ },
256+ }, nil )
257+
258+ m := & coreMessage.Message {
259+ Data : ad ,
260+ Source : 0 ,
261+ Destination : 10 ,
262+ }
263+ prop , err := s .handler .HandleMessage (m )
264+
265+ s .Nil (prop )
266+ s .NotNil (err )
267+
268+ err = <- errChn
269+ s .NotNil (err )
270+ }
0 commit comments