sweep: make sure nil tx is handled

After previous commit, it should be clear that the tx may be failed to
created in a `TxFailed` event. We now make sure to catch it to avoid
panic.
This commit is contained in:
yyforyongyu committed 2024-12-20 17:54:00 +08:00
1 parent 78ce757e7b
commit 30ee450091
3 files changed
+35 -14

No files matched your search

+7 -7
View File
@@ -91,13 +91,6 @@ func TestBumpResultValidate(t *testing.T) {
}
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
// A failed event without a tx will give an error.
b = BumpResult{
Event: TxFailed,
Err: errDummy,
}
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
// A fatal event without a failure reason will give an error.
b = BumpResult{
Event: TxFailed,
@@ -118,6 +111,13 @@ func TestBumpResultValidate(t *testing.T) {
}
require.NoError(t, b.Validate())
// Tx is allowed to be nil in a TxFailed event.
b = BumpResult{
Event: TxFailed,
Err: errDummy,
}
require.NoError(t, b.Validate())
// Tx is allowed to be nil in a TxFatal event.
b = BumpResult{
Event: TxFatal,