Miscellaneous code quality improvements (#7414)

* anti-patterns

* performance issues

* handle skipped defer

* gazelle fix

* misc bug risks

* make logging of proposer slashings more robust

* simplify calling span.End()

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka
2020-10-04 17:03:10 +02:00
committed by GitHub
parent d9ae2073e2
commit 3e0b20529b
27 changed files with 98 additions and 64 deletions

View File

@@ -57,16 +57,20 @@ func keySetup() {
func TestMain(m *testing.M) {
dir := testutil.TempDir() + "/keystore1"
defer func() {
cleanup := func() {
if err := os.RemoveAll(dir); err != nil {
log.WithError(err).Debug("Cannot remove keystore folder")
}
}()
}
defer cleanup()
if err := v1.NewValidatorAccount(dir, "1234"); err != nil {
log.WithError(err).Debug("Cannot create validator account")
}
keySetup()
os.Exit(m.Run())
code := m.Run()
// os.Exit will prevent defer from being called
cleanup()
os.Exit(code)
}
func TestStop_CancelsContext(t *testing.T) {