Skip to content

Commit 65d1dbe

Browse files
committed
add missing test for GetGasPrice
1 parent ad756a2 commit 65d1dbe

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

core/retry_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,58 @@ func TestWaitForTransactionReceipt(t *testing.T) {
214214
}
215215
}
216216

217+
func TestGetGasPrice(t *testing.T) {
218+
219+
cmd, client, err := SetupAnvil(8545)
220+
if err != nil {
221+
t.Errorf("Error setting up Anvil: %s\n", err)
222+
}
223+
224+
// Assert Call succeeds when Anvil running
225+
receipt_function := utils.GetGasPrice(*client, *client)
226+
_, err = receipt_function()
227+
assert.NotNil(t, err, "Error Waiting for Transaction with Anvil Running: %s\n", err)
228+
if !strings.Contains(err.Error(), "not found") {
229+
t.Errorf("WaitForTransactionReceipt Emitted incorrect error: %s\n", err)
230+
return
231+
}
232+
233+
if err = cmd.Process.Kill(); err != nil {
234+
t.Errorf("Error killing process: %v\n", err)
235+
return
236+
}
237+
238+
receipt_function = utils.GetGasPrice(*client, *client)
239+
_, err = receipt_function()
240+
assert.NotNil(t, err)
241+
if _, ok := err.(retry.PermanentError); ok {
242+
t.Errorf("WaitForTransactionReceipt Emitted non Transient error: %s\n", err)
243+
return
244+
}
245+
if !strings.Contains(err.Error(), "connect: connection refused") {
246+
t.Errorf("WaitForTransactionReceipt Emitted non Transient error: %s\n", err)
247+
return
248+
}
249+
250+
cmd, client, err = SetupAnvil(8545)
251+
if err != nil {
252+
t.Errorf("Error setting up Anvil: %s\n", err)
253+
}
254+
255+
receipt_function = utils.GetGasPrice(*client, *client)
256+
_, err = receipt_function()
257+
assert.NotNil(t, err)
258+
if !strings.Contains(err.Error(), "not found") {
259+
t.Errorf("WaitForTransactionReceipt Emitted incorrect error: %s\n", err)
260+
return
261+
}
262+
263+
if err := cmd.Process.Kill(); err != nil {
264+
t.Errorf("Error killing process: %v\n", err)
265+
return
266+
}
267+
}
268+
217269
// NOTE: The following tests involving starting the aggregator panic after the connection to anvil is cut crashing the test runner.
218270
// The originates within the eigen-sdk and as of 8/11/24 is currently working to be fixed.
219271

0 commit comments

Comments
 (0)