diff options
author | 大彬 <hz_stb@163.com> | 2019-07-17 19:20:24 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2019-07-17 19:20:24 +0800 |
commit | 4ac04ae0feba560e93f0fad55772b8830b759d1b (patch) | |
tree | e3c966a6f538f7e7d4e4a9af9c35aad5386bd546 /les/api_test.go | |
parent | 8f80cafa108cf0a762e0e34a6a4cd04021139bd1 (diff) | |
download | go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar.gz go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar.bz2 go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar.lz go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar.xz go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.tar.zst go-tangerine-4ac04ae0feba560e93f0fad55772b8830b759d1b.zip |
all: replace fmt.Print* calls with t.Log* in tests (#19670)
Diffstat (limited to 'les/api_test.go')
-rw-r--r-- | les/api_test.go | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/les/api_test.go b/les/api_test.go index cec945962..6db9e5417 100644 --- a/les/api_test.go +++ b/les/api_test.go @@ -20,7 +20,6 @@ import ( "context" "errors" "flag" - "fmt" "io/ioutil" "math/rand" "os" @@ -41,7 +40,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/simulations" "github.com/ethereum/go-ethereum/p2p/simulations/adapters" "github.com/ethereum/go-ethereum/rpc" - colorable "github.com/mattn/go-colorable" + "github.com/mattn/go-colorable" ) /* @@ -100,7 +99,7 @@ func testCapacityAPI(t *testing.T, clientCount int) { totalCap := getTotalCap(ctx, t, serverRpcClient) minCap := getMinCap(ctx, t, serverRpcClient) testCap := totalCap * 3 / 4 - fmt.Printf("Server testCap: %d minCap: %d head number: %d head hash: %064x\n", testCap, minCap, headNum, headHash) + t.Logf("Server testCap: %d minCap: %d head number: %d head hash: %064x\n", testCap, minCap, headNum, headHash) reqMinCap := uint64(float64(testCap) * minRelCap / (minRelCap + float64(len(clients)-1))) if minCap > reqMinCap { t.Fatalf("Minimum client capacity (%d) bigger than required minimum for this test (%d)", minCap, reqMinCap) @@ -116,7 +115,7 @@ func testCapacityAPI(t *testing.T, clientCount int) { t.Fatalf("Failed to obtain rpc client: %v", err) } - fmt.Println("connecting client", i) + t.Log("connecting client", i) if i != freeIdx { setCapacity(ctx, t, serverRpcClient, client.ID(), testCap/uint64(len(clients))) } @@ -130,7 +129,7 @@ func testCapacityAPI(t *testing.T, clientCount int) { } num, hash := getHead(ctx, t, clientRpcClients[i]) if num == headNum && hash == headHash { - fmt.Println("client", i, "synced") + t.Log("client", i, "synced") break } time.Sleep(time.Millisecond * 200) @@ -225,12 +224,12 @@ func testCapacityAPI(t *testing.T, clientCount int) { } time.Sleep(flowcontrol.DecParamDelay) - fmt.Println("Starting measurement") - fmt.Printf("Relative weights:") + t.Log("Starting measurement") + t.Logf("Relative weights:") for i := range clients { - fmt.Printf(" %f", weights[i]) + t.Logf(" %f", weights[i]) } - fmt.Println() + t.Log() start := processedSince(nil) for { select { @@ -241,7 +240,7 @@ func testCapacityAPI(t *testing.T, clientCount int) { totalCap = getTotalCap(ctx, t, serverRpcClient) if totalCap < testCap { - fmt.Println("Total capacity underrun") + t.Log("Total capacity underrun") close(stop) wg.Wait() return false @@ -249,9 +248,9 @@ func testCapacityAPI(t *testing.T, clientCount int) { processed := processedSince(start) var avg uint64 - fmt.Printf("Processed") + t.Logf("Processed") for i, p := range processed { - fmt.Printf(" %d", p) + t.Logf(" %d", p) processed[i] = uint64(float64(p) / weights[i]) avg += processed[i] } @@ -261,7 +260,7 @@ func testCapacityAPI(t *testing.T, clientCount int) { var maxDev float64 for _, p := range processed { dev := float64(int64(p-avg)) / float64(avg) - fmt.Printf(" %7.4f", dev) + t.Logf(" %7.4f", dev) if dev < 0 { dev = -dev } @@ -269,13 +268,13 @@ func testCapacityAPI(t *testing.T, clientCount int) { maxDev = dev } } - fmt.Printf(" max deviation: %f totalCap: %d\n", maxDev, totalCap) + t.Logf(" max deviation: %f totalCap: %d\n", maxDev, totalCap) if maxDev <= testTolerance { - fmt.Println("success") + t.Log("success") break } } else { - fmt.Println() + t.Log() } time.Sleep(time.Millisecond * 200) } @@ -285,11 +284,11 @@ func testCapacityAPI(t *testing.T, clientCount int) { wg.Wait() for i, count := range reqCount { - fmt.Println("client", i, "processed", count) + t.Log("client", i, "processed", count) } return true }) { - fmt.Println("restarting test") + t.Log("restarting test") } } @@ -323,7 +322,7 @@ func testRequest(ctx context.Context, t *testing.T, client *rpc.Client) bool { // if err := client.CallContext(ctx, &res, "eth_getProof", addr, nil, "latest"); err != nil { err := client.CallContext(c, &res, "eth_getBalance", addr, "latest") if err != nil { - fmt.Println("request error:", err) + t.Log("request error:", err) } return err == nil } |