<commit_before>// Copyright (c) 2013 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package ldb_test

import (
	"github.com/conformal/btcdb"
	"github.com/conformal/btcwire"
	"os"
	"testing"
)

// we need to test for empty databas and make certain it returns proper value

func TestEmptyDB(t *testing.T) {

	dbname := "tstdbempty"
	_ = os.RemoveAll(dbname)
	db, err := btcdb.CreateDB("leveldb", dbname)
	if err != nil {
		t.Errorf("Failed to open test database %v", err)
		return
	}
	defer os.RemoveAll(dbname)

	// This is a reopen test
	db.Close()

	db, err = btcdb.OpenDB("leveldb", dbname)
	if err != nil {
		t.Errorf("Failed to open test database %v", err)
		return
	}
	defer db.Close()

	sha, height, err := db.NewestSha()
	if !sha.IsEqual(&btcwire.ShaHash{}) {
		t.Errorf("sha not nil")
	}
	if height != -1 {
		t.Errorf("height not -1 %v", height)
	}
}
<commit_msg>Update error message for zero hash change.<commit_after>// Copyright (c) 2013 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package ldb_test

import (
	"github.com/conformal/btcdb"
	"github.com/conformal/btcwire"
	"os"
	"testing"
)

// we need to test for empty databas and make certain it returns proper value

func TestEmptyDB(t *testing.T) {

	dbname := "tstdbempty"
	_ = os.RemoveAll(dbname)
	db, err := btcdb.CreateDB("leveldb", dbname)
	if err != nil {
		t.Errorf("Failed to open test database %v", err)
		return
	}
	defer os.RemoveAll(dbname)

	// This is a reopen test
	db.Close()

	db, err = btcdb.OpenDB("leveldb", dbname)
	if err != nil {
		t.Errorf("Failed to open test database %v", err)
		return
	}
	defer db.Close()

	sha, height, err := db.NewestSha()
	if !sha.IsEqual(&btcwire.ShaHash{}) {
		t.Errorf("sha not zero hash")
	}
	if height != -1 {
		t.Errorf("height not -1 %v", height)
	}
}

{'fraction_non_alphanumeric': 0.13530326594090203, 'fraction_numerical': 0.006220839813374806, 'mean_word_length': 3.498834498834499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3352674', 'n_tokens_mistral': 752, 'n_tokens_neox': 715, 'n_words': 227}