Unverified Commit a413a97a authored by vipwzw's avatar vipwzw Committed by GitHub

Merge pull request #691 from zzh33cn/dpos-v2

删除DPos部分无用代码及UT
parents c05c19a5 014ca885
......@@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"sync"
"syscall"
"time"
)
......@@ -88,50 +87,12 @@ func Fingerprint(slice []byte) []byte {
return fingerprint
}
// Kill ...
func Kill() error {
p, err := os.FindProcess(os.Getpid())
if err != nil {
return err
}
return p.Signal(syscall.SIGTERM)
}
// Exit ...
func Exit(s string) {
fmt.Printf(s + "\n")
os.Exit(1)
}
// Parallel ...
func Parallel(tasks ...func()) {
var wg sync.WaitGroup
wg.Add(len(tasks))
for _, task := range tasks {
go func(task func()) {
task()
wg.Done()
}(task)
}
wg.Wait()
}
// MinInt ...
func MinInt(a, b int) int {
if a < b {
return a
}
return b
}
// MaxInt ...
func MaxInt(a, b int) int {
if a > b {
return a
}
return b
}
// RandIntn ...
func RandIntn(n int) int {
if n <= 0 {
......
......@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"os"
"os/signal"
"strings"
"sync"
"testing"
......@@ -83,14 +82,6 @@ func TestFingerprint(t *testing.T) {
assert.True(t, bytes.Equal(finger, arr[0:6]))
}
func TestKill(t *testing.T) {
c := make(chan os.Signal)
signal.Notify(c)
go Kill()
s := <-c
assert.True(t, s.String() == "terminated")
}
var (
goIndex = 0
goIndexMutex sync.Mutex
......@@ -116,17 +107,6 @@ func TestParallel(t *testing.T) {
f2 := test
f2()
assert.True(t, goSum == 2)
/*
goSumMutex.Lock()
goSum = 0
goSumMutex.Unlock()
Parallel(f1, f2)
goSumMutex.Lock()
assert.True(t, goSum == 2)
goSumMutex.Unlock()
*/
}
func TestRandInt63n(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment