trie, rpc, cmd/geth: fix tests on 32-bit and windows + minor rpc fixes (#21871)
* trie: fix tests to work on 32-bit systems * les: make test work on 32-bit platform * cmd/geth: fix windows-issues on tests * trie: improve balance * cmd/geth: make account tests less verbose + less mem intense * rpc: make debug-level log output less verbose * cmd/geth: lint
This commit is contained in:
committed by
GitHub
parent
f1e1d9f874
commit
6f88d6530a
@ -27,6 +27,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"testing"
|
||||
"text/template"
|
||||
@ -55,10 +56,13 @@ type TestCmd struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
var id int32
|
||||
|
||||
// Run exec's the current binary using name as argv[0] which will trigger the
|
||||
// reexec init function for that name (e.g. "geth-test" in cmd/geth/run_test.go)
|
||||
func (tt *TestCmd) Run(name string, args ...string) {
|
||||
tt.stderr = &testlogger{t: tt.T}
|
||||
id := atomic.AddInt32(&id, 1)
|
||||
tt.stderr = &testlogger{t: tt.T, name: fmt.Sprintf("%d", id)}
|
||||
tt.cmd = &exec.Cmd{
|
||||
Path: reexec.Self(),
|
||||
Args: append([]string{name}, args...),
|
||||
@ -238,16 +242,17 @@ func (tt *TestCmd) withKillTimeout(fn func()) {
|
||||
// testlogger logs all written lines via t.Log and also
|
||||
// collects them for later inspection.
|
||||
type testlogger struct {
|
||||
t *testing.T
|
||||
mu sync.Mutex
|
||||
buf bytes.Buffer
|
||||
t *testing.T
|
||||
mu sync.Mutex
|
||||
buf bytes.Buffer
|
||||
name string
|
||||
}
|
||||
|
||||
func (tl *testlogger) Write(b []byte) (n int, err error) {
|
||||
lines := bytes.Split(b, []byte("\n"))
|
||||
for _, line := range lines {
|
||||
if len(line) > 0 {
|
||||
tl.t.Logf("(stderr) %s", line)
|
||||
tl.t.Logf("(stderr:%v) %s", tl.name, line)
|
||||
}
|
||||
}
|
||||
tl.mu.Lock()
|
||||
|
Reference in New Issue
Block a user