Skip to content

Commit 78dddb4

Browse files
committed
fix: tests
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
1 parent ee3fcd3 commit 78dddb4

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

chains/lighter/message/lighter_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,48 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
197197
s.NotNil(err)
198198
}
199199

200+
func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidAsset() {
201+
s.mockCommunication.EXPECT().Broadcast(
202+
gomock.Any(),
203+
gomock.Any(),
204+
comm.LighterMsg,
205+
"lighter",
206+
).Return(nil)
207+
p, _ := pstoremem.NewPeerstore()
208+
s.mockHost.EXPECT().Peerstore().Return(p)
209+
210+
errChn := make(chan error, 1)
211+
ad := &message.LighterData{
212+
ErrChn: errChn,
213+
Nonce: big.NewInt(101),
214+
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
215+
OrderHash: "orderHash",
216+
DepositTxHash: "orderHash",
217+
}
218+
s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(&lighter.LighterTx{
219+
Type: lighter.TxTypeL2Withdraw,
220+
Transfer: &lighter.Transfer{
221+
Amount: 2000001,
222+
AssetIndex: 2,
223+
ToAccountIndex: 3,
224+
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
225+
},
226+
}, nil)
227+
228+
m := &coreMessage.Message{
229+
Data: ad,
230+
Source: 0,
231+
Destination: 10,
232+
}
233+
prop, err := s.handler.HandleMessage(m)
234+
235+
s.Nil(prop)
236+
s.NotNil(err)
237+
238+
err = <-errChn
239+
s.NotNil(err)
240+
}
241+
200242
func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidAccount() {
201243
s.mockCommunication.EXPECT().Broadcast(
202244
gomock.Any(),

protocol/lighter/mock/mockData.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package mock
33

44
const LighterMockResponse = `
5-
{"code":200,"hash":"1e16eea4ad2ea1db483e7a0aeea2149fcafd96da3b9e7ecab5e95506f002182d1809858336e2af22","type":12,"info":"{\"FromAccountIndex\":283390,\"ApiKeyIndex\":0,\"ToAccountIndex\":3,\"USDCAmount\":2000000,\"Fee\":3000000,\"Memo\":[238,123,250,212,202,237,62,98,106,248,169,199,213,3,76,213,137,238,73,144,0,0,0,0,0,0,0,0,0,0,0,0],\"ExpiredAt\":1761149674469,\"Nonce\":2,\"Sig\":\"crr/TWDu2CzHpkOtGaTIow70UcgsdfChqSYurrEoFO/K+f9nZHvpOzNVXtZQBf7JhhVyMK9dDbzgt3nUK7z9N/GdbH/NakIGHzVod+9ULhQ=\",\"L1Sig\":\"0x320bdc9a593130a7e25103a572458188dd4e2efdb18c5d862c7e54da10d780fe751b444a259195baa4b5a7e3dc600dfa2227ec077a09919f3f97a736475eea471c\"}","event_info":"{\"f\":283390,\"t\":3,\"u\":2000000,\"fee\":3000000,\"ae\":\"\"}","status":3,"transaction_index":16,"l1_address":"0xEe7BfAD4caEd3e626AF8a9C7d5034CD589EE4990","account_index":283390,"nonce":2,"expire_at":1761149674469,"block_height":70687079,"queued_at":1761149084285,"sequence_index":16778685698,"parent_hash":"","committed_at":0,"verified_at":0,"executed_at":1761149084292}
5+
{"code":200,"hash":"1e16eea4ad2ea1db483e7a0aeea2149fcafd96da3b9e7ecab5e95506f002182d1809858336e2af22","type":12,"info":"{\"FromAccountIndex\":283390,\"ApiKeyIndex\":0,\"ToAccountIndex\":3,\"Amount\":2000000,\"AssetIndex\":3,\"Fee\":3000000,\"Memo\":[238,123,250,212,202,237,62,98,106,248,169,199,213,3,76,213,137,238,73,144,0,0,0,0,0,0,0,0,0,0,0,0],\"ExpiredAt\":1761149674469,\"Nonce\":2,\"Sig\":\"crr/TWDu2CzHpkOtGaTIow70UcgsdfChqSYurrEoFO/K+f9nZHvpOzNVXtZQBf7JhhVyMK9dDbzgt3nUK7z9N/GdbH/NakIGHzVod+9ULhQ=\",\"L1Sig\":\"0x320bdc9a593130a7e25103a572458188dd4e2efdb18c5d862c7e54da10d780fe751b444a259195baa4b5a7e3dc600dfa2227ec077a09919f3f97a736475eea471c\"}","event_info":"{\"f\":283390,\"t\":3,\"u\":2000000,\"fee\":3000000,\"ae\":\"\"}","status":3,"transaction_index":16,"l1_address":"0xEe7BfAD4caEd3e626AF8a9C7d5034CD589EE4990","account_index":283390,"nonce":2,"expire_at":1761149674469,"block_height":70687079,"queued_at":1761149084285,"sequence_index":16778685698,"parent_hash":"","committed_at":0,"verified_at":0,"executed_at":1761149084292}
66
`
77

8-
const ExpectedLighterResponse = `{"code":200,"hash":"1e16eea4ad2ea1db483e7a0aeea2149fcafd96da3b9e7ecab5e95506f002182d1809858336e2af22","type":12,"info":"{\"FromAccountIndex\":283390,\"ApiKeyIndex\":0,\"ToAccountIndex\":3,\"USDCAmount\":2000000,\"Fee\":3000000,\"Memo\":[238,123,250,212,202,237,62,98,106,248,169,199,213,3,76,213,137,238,73,144,0,0,0,0,0,0,0,0,0,0,0,0],\"ExpiredAt\":1761149674469,\"Nonce\":2,\"Sig\":\"crr/TWDu2CzHpkOtGaTIow70UcgsdfChqSYurrEoFO/K+f9nZHvpOzNVXtZQBf7JhhVyMK9dDbzgt3nUK7z9N/GdbH/NakIGHzVod+9ULhQ=\",\"L1Sig\":\"0x320bdc9a593130a7e25103a572458188dd4e2efdb18c5d862c7e54da10d780fe751b444a259195baa4b5a7e3dc600dfa2227ec077a09919f3f97a736475eea471c\"}","event_info":"{\"f\":283390,\"t\":3,\"u\":2000000,\"fee\":3000000,\"ae\":\"\"}","status":3,"transaction_index":16,"l1_address":"0xEe7BfAD4caEd3e626AF8a9C7d5034CD589EE4990","account_index":283390,"nonce":2,"expire_at":1761149674469,"block_height":70687079,"queued_at":1761149084285,"sequence_index":16778685698,"parent_hash":"","committed_at":0,"verified_at":0,"executed_at":1761149084292}`
8+
const ExpectedLighterResponse = `{"code":200,"hash":"1e16eea4ad2ea1db483e7a0aeea2149fcafd96da3b9e7ecab5e95506f002182d1809858336e2af22","type":12,"info":"{\"FromAccountIndex\":283390,\"ApiKeyIndex\":0,\"ToAccountIndex\":3,\"Amount\":2000000,\"AssetIndex\":3,\"Fee\":3000000,\"Memo\":[238,123,250,212,202,237,62,98,106,248,169,199,213,3,76,213,137,238,73,144,0,0,0,0,0,0,0,0,0,0,0,0],\"ExpiredAt\":1761149674469,\"Nonce\":2,\"Sig\":\"crr/TWDu2CzHpkOtGaTIow70UcgsdfChqSYurrEoFO/K+f9nZHvpOzNVXtZQBf7JhhVyMK9dDbzgt3nUK7z9N/GdbH/NakIGHzVod+9ULhQ=\",\"L1Sig\":\"0x320bdc9a593130a7e25103a572458188dd4e2efdb18c5d862c7e54da10d780fe751b444a259195baa4b5a7e3dc600dfa2227ec077a09919f3f97a736475eea471c\"}","event_info":"{\"f\":283390,\"t\":3,\"u\":2000000,\"fee\":3000000,\"ae\":\"\"}","status":3,"transaction_index":16,"l1_address":"0xEe7BfAD4caEd3e626AF8a9C7d5034CD589EE4990","account_index":283390,"nonce":2,"expire_at":1761149674469,"block_height":70687079,"queued_at":1761149084285,"sequence_index":16778685698,"parent_hash":"","committed_at":0,"verified_at":0,"executed_at":1761149084292}`

0 commit comments

Comments
 (0)