Commit f7fdf9e0 authored by 张振华's avatar 张振华

Merge branch 'dpos-v2' of https://github.com/zzh33cn/plugin into dpos-v2

parents 5b4e5c30 93752812
...@@ -368,7 +368,7 @@ OuterLoop: ...@@ -368,7 +368,7 @@ OuterLoop:
csState.SetPrivValidator(client.privValidator, client.ValidatorIndex()) csState.SetPrivValidator(client.privValidator, client.ValidatorIndex())
// Create & add listener // Create & add listener
protocol, listeningAddress := "tcp", "0.0.0.0:" + dposPort protocol, listeningAddress := "tcp", "0.0.0.0:"+dposPort
node := NewNode(validatorNodes, protocol, listeningAddress, client.privKey, valMgr.ChainID, dposVersion, csState) node := NewNode(validatorNodes, protocol, listeningAddress, client.privKey, valMgr.ChainID, dposVersion, csState)
client.node = node client.node = node
...@@ -772,6 +772,6 @@ func (client *Client) SetTestFlag() { ...@@ -772,6 +772,6 @@ func (client *Client) SetTestFlag() {
} }
// GetNode return the pointer to Node // GetNode return the pointer to Node
func (client *Client) GetNode() *Node{ func (client *Client) GetNode() *Node {
return client.node return client.node
} }
...@@ -197,7 +197,7 @@ func (node *Node) Start(testFlag bool) { ...@@ -197,7 +197,7 @@ func (node *Node) Start(testFlag bool) {
addr := node.seeds[i] addr := node.seeds[i]
ip, _ := splitHostPort(addr) ip, _ := splitHostPort(addr)
_, ok := node.localIPs[ip] _, ok := node.localIPs[ip]
if ok && !testFlag{ if ok && !testFlag {
dposlog.Info("find our ip ", "ourip", ip) dposlog.Info("find our ip ", "ourip", ip)
node.IP = ip node.IP = ip
return return
......
...@@ -5,6 +5,12 @@ import ( ...@@ -5,6 +5,12 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os"
"sync"
"testing"
"time"
"github.com/33cn/chain33/common/crypto" "github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/executor" "github.com/33cn/chain33/executor"
"github.com/33cn/chain33/p2p" "github.com/33cn/chain33/p2p"
...@@ -13,11 +19,6 @@ import ( ...@@ -13,11 +19,6 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"io/ioutil"
"os"
"sync"
"testing"
"time"
"github.com/33cn/chain33/blockchain" "github.com/33cn/chain33/blockchain"
"github.com/33cn/chain33/mempool" "github.com/33cn/chain33/mempool"
...@@ -190,7 +191,7 @@ cryptoPath="authdir/crypto" ...@@ -190,7 +191,7 @@ cryptoPath="authdir/crypto"
# 带证书签名类型,支持"auth_ecdsa", "auth_sm2" # 带证书签名类型,支持"auth_ecdsa", "auth_sm2"
signType="auth_ecdsa" signType="auth_ecdsa"
` `
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
config2 = `Title="local" config2 = `Title="local"
[log] [log]
...@@ -365,6 +366,7 @@ cryptoPath="authdir/crypto" ...@@ -365,6 +366,7 @@ cryptoPath="authdir/crypto"
signType="auth_ecdsa" signType="auth_ecdsa"
` `
) )
func init() { func init() {
cr2, err := crypto.New(types.GetSignName("", types.ED25519)) cr2, err := crypto.New(types.GetSignName("", types.ED25519))
if err != nil { if err != nil {
...@@ -398,19 +400,18 @@ func Init() { ...@@ -398,19 +400,18 @@ func Init() {
ioutil.WriteFile("chain33.test2.toml", []byte(config2), 0664) ioutil.WriteFile("chain33.test2.toml", []byte(config2), 0664)
} }
func TestParallel(t *testing.T) { func TestParallel(t *testing.T) {
Parallel(func () { Parallel(func() {
mutx.Lock() mutx.Lock()
sum += 1 sum += 1
mutx.Unlock() mutx.Unlock()
}, },
func () { func() {
mutx.Lock() mutx.Lock()
sum += 2 sum += 2
mutx.Unlock() mutx.Unlock()
}, },
func () { func() {
mutx.Lock() mutx.Lock()
sum += 3 sum += 3
mutx.Unlock() mutx.Unlock()
...@@ -500,7 +501,6 @@ func TestNode(t *testing.T) { ...@@ -500,7 +501,6 @@ func TestNode(t *testing.T) {
require.Nil(t, cs1.(*Client).GetNode().CompatibleWith(nodeinfo)) require.Nil(t, cs1.(*Client).GetNode().CompatibleWith(nodeinfo))
fmt.Println("TestNodeCompatibleWith ok") fmt.Println("TestNodeCompatibleWith ok")
//time.Sleep(2 * time.Second) //time.Sleep(2 * time.Second)
fmt.Println(q1.Name()) fmt.Println(q1.Name())
...@@ -532,7 +532,6 @@ func TestNode(t *testing.T) { ...@@ -532,7 +532,6 @@ func TestNode(t *testing.T) {
fmt.Println("======= cs1 is not running=======") fmt.Println("======= cs1 is not running=======")
} }
//cs2.(*Client).StopC() //cs2.(*Client).StopC()
if cs2.(*Client).GetNode().IsRunning() { if cs2.(*Client).GetNode().IsRunning() {
fmt.Println("=======cs2 is running=======") fmt.Println("=======cs2 is running=======")
...@@ -568,7 +567,6 @@ func clearTestData1() { ...@@ -568,7 +567,6 @@ func clearTestData1() {
fmt.Println("test data clear successfully!") fmt.Println("test data clear successfully!")
} }
func initEnvDpos1(configName string) (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Module, *executor.Executor, queue.Module, queue.Module) { func initEnvDpos1(configName string) (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Module, *executor.Executor, queue.Module, queue.Module) {
var q = queue.New("channel") var q = queue.New("channel")
flag.Parse() flag.Parse()
...@@ -625,7 +623,6 @@ func initEnvDpos2(configName string) (queue.Queue, *blockchain.BlockChain, queue ...@@ -625,7 +623,6 @@ func initEnvDpos2(configName string) (queue.Queue, *blockchain.BlockChain, queue
cs.(*Client).SetTestFlag() cs.(*Client).SetTestFlag()
cs.SetQueueClient(q.Client()) cs.SetQueueClient(q.Client())
mem := mempool.New(cfg.Mempool, nil) mem := mempool.New(cfg.Mempool, nil)
mem.SetQueueClient(q.Client()) mem.SetQueueClient(q.Client())
network := p2p.New(cfg.P2P) network := p2p.New(cfg.P2P)
...@@ -638,4 +635,3 @@ func initEnvDpos2(configName string) (queue.Queue, *blockchain.BlockChain, queue ...@@ -638,4 +635,3 @@ func initEnvDpos2(configName string) (queue.Queue, *blockchain.BlockChain, queue
return q, chain, s, mem, exec, cs, network return q, chain, s, mem, exec, cs, network
} }
...@@ -10,11 +10,12 @@ import ( ...@@ -10,11 +10,12 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/33cn/chain33/common/address"
"io/ioutil" "io/ioutil"
"os" "os"
"sync" "sync"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto" "github.com/33cn/chain33/common/crypto"
vrf "github.com/33cn/chain33/common/vrf/secp256k1" vrf "github.com/33cn/chain33/common/vrf/secp256k1"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
......
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