From 6f290733c367c4e9a15296f82abddde0933f70bd Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 20 Feb 2020 14:09:40 +0800 Subject: [PATCH 1/5] accounts/abi/bind: raise timeout allowance --- accounts/abi/bind/bind_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index fa1a7b1ca77d..697c3ebe0ab9 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -1384,7 +1384,7 @@ var bindTests = []struct { if n != 3 { t.Fatalf("Invalid bar0 event") } - case <-time.NewTimer(100 * time.Millisecond).C: + case <-time.NewTimer(3 * time.Second).C: t.Fatalf("Wait bar0 event timeout") } @@ -1395,7 +1395,7 @@ var bindTests = []struct { if n != 1 { t.Fatalf("Invalid bar event") } - case <-time.NewTimer(100 * time.Millisecond).C: + case <-time.NewTimer(3 * time.Second).C: t.Fatalf("Wait bar event timeout") } close(stopCh) @@ -1589,7 +1589,7 @@ var bindTests = []struct { // Tests that packages generated by the binder can be successfully compiled and // the requested tester run against it. -func TestGolangBindings(t *testing.T) { +func TestGolangBindingTestOverloads(t *testing.T) { // Skip the test if no Go command can be found gocmd := runtime.GOROOT() + "/bin/go" if !common.FileExist(gocmd) { From 8f1377585c53c6c1a2b529c26126b530416f4767 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 20 Feb 2020 14:52:55 +0800 Subject: [PATCH 2/5] miner: fix miner test --- miner/worker_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/miner/worker_test.go b/miner/worker_test.go index 81fb8f1b9477..78e09a17675c 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -215,12 +215,16 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{}, nil) defer chain.Stop() - loopErr := make(chan error) - newBlock := make(chan struct{}) + var ( + loopErr = make(chan error) + newBlock = make(chan struct{}) + subscribe = make(chan struct{}) + ) listenNewBlock := func() { sub := w.mux.Subscribe(core.NewMinedBlockEvent{}) defer sub.Unsubscribe() + subscribe <- struct{}{} for item := range sub.Chan() { block := item.Data.(core.NewMinedBlockEvent).Block _, err := chain.InsertChain([]*types.Block{block}) @@ -234,9 +238,11 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { w.skipSealHook = func(task *task) bool { return len(task.receipts) == 0 } - w.start() // Start mining! go listenNewBlock() + <-subscribe // Ensure the subscription is created + w.start() // Start mining! + for i := 0; i < 5; i++ { b.txPool.AddLocal(b.newRandomTx(true)) b.txPool.AddLocal(b.newRandomTx(false)) From 5b5a14722729eb6a6259246aca1de54a6a3fee46 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 20 Feb 2020 15:04:27 +0800 Subject: [PATCH 3/5] account/abi/bind: fix test name --- accounts/abi/bind/bind_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index 697c3ebe0ab9..bbc6d8a45ab1 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -1589,7 +1589,7 @@ var bindTests = []struct { // Tests that packages generated by the binder can be successfully compiled and // the requested tester run against it. -func TestGolangBindingTestOverloads(t *testing.T) { +func TestGolangBindings(t *testing.T) { // Skip the test if no Go command can be found gocmd := runtime.GOROOT() + "/bin/go" if !common.FileExist(gocmd) { From 33400e64ebba0bc1452c4424f6eeb465b19a1205 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 20 Feb 2020 15:42:32 +0800 Subject: [PATCH 4/5] les: fix les timeout unit test --- les/clientpool_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/les/clientpool_test.go b/les/clientpool_test.go index 06f782ac96ef..e83fb274af7c 100644 --- a/les/clientpool_test.go +++ b/les/clientpool_test.go @@ -527,7 +527,7 @@ func TestNodeDBExpiration(t *testing.T) { if iterated != 4 { t.Fatalf("Failed to evict useless negative balances, want %v, got %d", 4, iterated) } - + time.Sleep(100 * time.Millisecond) // Ensure the callback has been registered to virtual clock for _, c := range cases { ndb.setNB(c.ip, c.balance) } From fbf97da01ce1274a9997b2cb9dc7079b65a7c835 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 20 Feb 2020 19:14:11 +0800 Subject: [PATCH 5/5] les: use waitForTimer to replace time sleep --- les/clientpool_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/les/clientpool_test.go b/les/clientpool_test.go index e83fb274af7c..6308113fe74c 100644 --- a/les/clientpool_test.go +++ b/les/clientpool_test.go @@ -517,7 +517,7 @@ func TestNodeDBExpiration(t *testing.T) { for _, c := range cases { ndb.setNB(c.ip, c.balance) } - time.Sleep(100 * time.Millisecond) // Ensure the db expirer is registered. + clock.WaitForTimers(1) clock.Run(time.Hour + time.Minute) select { case <-done: @@ -527,7 +527,7 @@ func TestNodeDBExpiration(t *testing.T) { if iterated != 4 { t.Fatalf("Failed to evict useless negative balances, want %v, got %d", 4, iterated) } - time.Sleep(100 * time.Millisecond) // Ensure the callback has been registered to virtual clock + clock.WaitForTimers(1) for _, c := range cases { ndb.setNB(c.ip, c.balance) }