mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
Fix race testing
This commit is contained in:
parent
fb64314d1c
commit
d24e4cb821
@ -60,7 +60,7 @@ func startNewConsensusStateAndWaitForBlock(t *testing.T, lastBlockHeight int64,
|
||||
|
||||
bytes, _ := ioutil.ReadFile(cs.config.WalFile())
|
||||
// fmt.Printf("====== WAL: \n\r%s\n", bytes)
|
||||
t.Logf("====== WAL: \n\r%s\n", bytes)
|
||||
t.Logf("====== WAL: \n\r%X\n", bytes)
|
||||
|
||||
err := cs.Start()
|
||||
require.NoError(t, err)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
@ -15,6 +16,7 @@ import (
|
||||
// Block defines the atomic unit of a Tendermint blockchain.
|
||||
// TODO: add Version byte
|
||||
type Block struct {
|
||||
mtx sync.Mutex
|
||||
*Header `json:"header"`
|
||||
*Data `json:"data"`
|
||||
Evidence EvidenceData `json:"evidence"`
|
||||
@ -35,7 +37,7 @@ func MakeBlock(height int64, txs []Tx, commit *Commit) *Block {
|
||||
Txs: txs,
|
||||
},
|
||||
}
|
||||
block.FillHeader()
|
||||
block.fillHeader()
|
||||
return block
|
||||
}
|
||||
|
||||
@ -68,8 +70,8 @@ func (b *Block) ValidateBasic() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FillHeader fills in any remaining header fields that are a function of the block data
|
||||
func (b *Block) FillHeader() {
|
||||
// fillHeader fills in any remaining header fields that are a function of the block data
|
||||
func (b *Block) fillHeader() {
|
||||
if b.LastCommitHash == nil {
|
||||
b.LastCommitHash = b.LastCommit.Hash()
|
||||
}
|
||||
@ -84,10 +86,16 @@ func (b *Block) FillHeader() {
|
||||
// Hash computes and returns the block hash.
|
||||
// If the block is incomplete, block hash is nil for safety.
|
||||
func (b *Block) Hash() cmn.HexBytes {
|
||||
if b == nil {
|
||||
return nil
|
||||
}
|
||||
b.mtx.Lock()
|
||||
defer b.mtx.Unlock()
|
||||
|
||||
if b == nil || b.Header == nil || b.Data == nil || b.LastCommit == nil {
|
||||
return nil
|
||||
}
|
||||
b.FillHeader()
|
||||
b.fillHeader()
|
||||
return b.Header.Hash()
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ func TestSocketPVDeadline(t *testing.T) {
|
||||
)
|
||||
)
|
||||
|
||||
SocketPVConnDeadline(10 * time.Millisecond)(sc)
|
||||
SocketPVConnDeadline(100 * time.Millisecond)(sc)
|
||||
SocketPVConnWait(500 * time.Millisecond)(sc)
|
||||
|
||||
go func(sc *SocketPV) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user