Browse Source

fixes after my own review

pull/930/head
Anton Kaliaev 7 years ago
parent
commit
5cb936fa00
No known key found for this signature in database GPG Key ID: 7B6881D965918214
3 changed files with 24 additions and 18 deletions
  1. +9
    -6
      consensus/replay_test.go
  2. +13
    -10
      consensus/wal_generator.go
  3. +2
    -2
      consensus/wal_test.go

+ 9
- 6
consensus/replay_test.go View File

@ -264,9 +264,12 @@ func (w *crashingWAL) Wait() { w.next.Wait() }
//------------------------------------------------------------------------------------------
// Handshake Tests
var (
const (
NUM_BLOCKS = 6
mempool = types.MockMempool{}
)
var (
mempool = types.MockMempool{}
)
//---------------------------------------
@ -305,12 +308,12 @@ func TestHandshakeReplayNone(t *testing.T) {
}
}
func writeWAL(walMsgs []byte) string {
func tempWALWithData(data []byte) string {
walFile, err := ioutil.TempFile("", "wal")
if err != nil {
panic(fmt.Errorf("failed to create temp WAL file: %v", err))
}
_, err = walFile.Write(walMsgs)
_, err = walFile.Write(data)
if err != nil {
panic(fmt.Errorf("failed to write to temp WAL file: %v", err))
}
@ -324,11 +327,11 @@ func writeWAL(walMsgs []byte) string {
func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
config := ResetConfig("proxy_test_")
walBody, err := GenWAL(NUM_BLOCKS)
walBody, err := WALWithNBlocks(NUM_BLOCKS)
if err != nil {
t.Fatal(err)
}
walFile := writeWAL(walBody)
walFile := tempWALWithData(walBody)
config.Consensus.SetWalFile(walFile)
privVal := types.LoadPrivValidatorFS(config.PrivValidatorFile())


consensus/walgen.go → consensus/wal_generator.go View File


+ 2
- 2
consensus/wal_test.go View File

@ -42,11 +42,11 @@ func TestWALEncoderDecoder(t *testing.T) {
}
func TestSearchForEndHeight(t *testing.T) {
walBody, err := GenWAL(6)
walBody, err := WALWithNBlocks(6)
if err != nil {
t.Fatal(err)
}
walFile := writeWAL(walBody)
walFile := tempWALWithData(walBody)
wal, err := NewWAL(walFile, false)
if err != nil {


Loading…
Cancel
Save