refactor: handle unsub when t.Fatalf

This commit is contained in:
winniehere 2024-06-19 03:35:58 +00:00
parent 71fa1fe0b6
commit fe4870e911

View file

@ -314,6 +314,8 @@ func TestWalletNotifications(t *testing.T) {
// Add a new account and ensure wallet notifications arrives // Add a new account and ensure wallet notifications arrives
account, err := ks.NewAccount("") account, err := ks.NewAccount("")
if err != nil { if err != nil {
// Shut down the event collector and check events.
sub.Unsubscribe()
t.Fatalf("failed to create test account: %v", err) t.Fatalf("failed to create test account: %v", err)
} }
live[account.Address] = account live[account.Address] = account
@ -326,6 +328,8 @@ func TestWalletNotifications(t *testing.T) {
break break
} }
if err := ks.Delete(account, ""); err != nil { if err := ks.Delete(account, ""); err != nil {
// Shut down the event collector and check events.
sub.Unsubscribe()
t.Fatalf("failed to delete test account: %v", err) t.Fatalf("failed to delete test account: %v", err)
} }
delete(live, account.Address) delete(live, account.Address)