@@ -24,6 +24,7 @@ TEST CASES - logic_gas_payment.go
2424* PayForGas (invalid) with zero amount
2525* PayForGas (invalid) with an invalid sender
2626* PayForGas (invalid) with a non-funded sender
27+ * PayForGas (invalid) insufficient amount
2728* PayForGas (valid)
2829* Claim (invalid) for non-existing IGP
2930* Claim (invalid) from non-owner address
@@ -90,8 +91,8 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
9091 IgpId : nonExistingIgp ,
9192 MessageId : messageIdTest ,
9293 DestinationDomain : 1 ,
93- GasLimit : math .NewInt (1 ),
94- Amount : sdk .NewCoin (denom , math .NewInt (10 )),
94+ GasLimit : math .NewInt (50000 ),
95+ Amount : sdk .NewCoin (denom , math .NewInt (250000 )),
9596 })
9697
9798 // Assert
@@ -132,14 +133,56 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
132133 IgpId : igpId ,
133134 MessageId : messageIdTest ,
134135 DestinationDomain : 1 ,
135- GasLimit : math .NewInt (1 ),
136+ GasLimit : math .NewInt (50000 ),
136137 Amount : sdk .NewCoin (denom , math .ZeroInt ()),
137138 })
138139
139140 // Assert
140141 Expect (err .Error ()).To (Equal ("amount must be greater than zero" ))
141142 })
142143
144+ It ("PayForGas (invalid) insufficient amount" , func () {
145+ // NOTE: Negative amount panics at sdk.NewCoins()
146+ // Arrange
147+ res , err := s .RunTx (& types.MsgCreateIgp {
148+ Owner : creator .Address ,
149+ Denom : denom ,
150+ })
151+ Expect (err ).To (BeNil ())
152+
153+ var response types.MsgCreateIgpResponse
154+ err = proto .Unmarshal (res .MsgResponses [0 ].Value , & response )
155+ Expect (err ).To (BeNil ())
156+ igpId := response .Id
157+
158+ _ , err = s .RunTx (& types.MsgSetDestinationGasConfig {
159+ Owner : creator .Address ,
160+ IgpId : igpId ,
161+ DestinationGasConfig : & types.DestinationGasConfig {
162+ RemoteDomain : 1 ,
163+ GasOracle : & types.GasOracle {
164+ TokenExchangeRate : math .NewInt (1e10 ),
165+ GasPrice : math .NewInt (1 ),
166+ },
167+ GasOverhead : math .NewInt (200000 ),
168+ },
169+ })
170+ Expect (err ).To (BeNil ())
171+
172+ // Act
173+ _ , err = s .RunTx (& types.MsgPayForGas {
174+ Sender : gasPayer .Address ,
175+ IgpId : igpId ,
176+ MessageId : messageIdTest ,
177+ DestinationDomain : 1 ,
178+ GasLimit : math .NewInt (50000 ),
179+ Amount : sdk .NewCoin (denom , math .NewInt (5 )),
180+ })
181+
182+ // Assert
183+ Expect (err .Error ()).To (Equal ("required payment exceeds max hyperlane fee: 250000acoin" ))
184+ })
185+
143186 It ("PayForGas (invalid) with an invalid sender" , func () {
144187 // Arrange
145188 res , err := s .RunTx (& types.MsgCreateIgp {
@@ -174,7 +217,7 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
174217 MessageId : messageIdTest ,
175218 DestinationDomain : 1 ,
176219 GasLimit : math .NewInt (50000 ),
177- Amount : sdk .NewCoin (denom , math .NewInt (10 )),
220+ Amount : sdk .NewCoin (denom , math .NewInt (250000 )),
178221 })
179222
180223 // Assert
@@ -215,16 +258,16 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
215258 MessageId : messageIdTest ,
216259 DestinationDomain : 1 ,
217260 GasLimit : math .NewInt (50000 ),
218- Amount : sdk .NewCoin (denom , math .NewInt (10 )),
261+ Amount : sdk .NewCoin (denom , math .NewInt (250000 )),
219262 })
220263
221264 // Assert
222- Expect (err .Error ()).To (Equal ("spendable balance 0acoin is smaller than 10acoin : insufficient funds" ))
265+ Expect (err .Error ()).To (Equal ("spendable balance 0acoin is smaller than 250000acoin : insufficient funds" ))
223266 })
224267
225268 It ("PayForGas (valid)" , func () {
226269 // Arrange
227- gasAmount := math .NewInt (10 )
270+ gasAmount := math .NewInt (250000 )
228271
229272 err := s .MintBaseCoins (gasPayer .Address , 1_000_000 )
230273 Expect (err ).To (BeNil ())
@@ -263,7 +306,7 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
263306 MessageId : messageIdTest ,
264307 DestinationDomain : 1 ,
265308 GasLimit : math .NewInt (50000 ),
266- Amount : sdk .NewCoin (denom , math .NewInt (10 )),
309+ Amount : sdk .NewCoin (denom , math .NewInt (250000 )),
267310 })
268311
269312 // Assert
@@ -293,7 +336,7 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
293336
294337 It ("Claim (invalid) from non-owner address" , func () {
295338 // Arrange
296- gasAmount := math .NewInt (10 )
339+ gasAmount := math .NewInt (200000 )
297340
298341 err := s .MintBaseCoins (gasPayer .Address , 1_000_000 )
299342 Expect (err ).To (BeNil ())
@@ -355,7 +398,7 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
355398
356399 It ("Claim (invalid) with invalid address" , func () {
357400 // Arrange
358- gasAmount := math .NewInt (10 )
401+ gasAmount := math .NewInt (250000 )
359402
360403 err := s .MintBaseCoins (gasPayer .Address , 1_000_000 )
361404 Expect (err ).To (BeNil ())
@@ -445,7 +488,7 @@ var _ = Describe("logic_gas_payment.go", Ordered, func() {
445488
446489 It ("Claim (valid)" , func () {
447490 // Arrange
448- gasAmount := math .NewInt (10 )
491+ gasAmount := math .NewInt (250000 )
449492
450493 err := s .MintBaseCoins (gasPayer .Address , 1_000_000 )
451494 Expect (err ).To (BeNil ())
0 commit comments