Browse Source

Delete tmp folders from tests, Resolve #105

feature/sql-semaphore1
Eduard S 4 years ago
parent
commit
88ddbbcddc
9 changed files with 32 additions and 0 deletions
  1. +5
    -0
      api/api_test.go
  2. +3
    -0
      batchbuilder/batchbuilder_test.go
  3. +3
    -0
      coordinator/coordinator_test.go
  4. +7
    -0
      db/statedb/statedb_test.go
  5. +4
    -0
      db/statedb/txprocessors_test.go
  6. +2
    -0
      db/statedb/utils_test.go
  7. +5
    -0
      eth/main_test.go
  8. +1
    -0
      synchronizer/synchronizer_test.go
  9. +2
    -0
      txselector/txselector_test.go

+ 5
- 0
api/api_test.go

@ -151,6 +151,11 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
panic(err)
}
}()
sdb, err := statedb.NewStateDB(dir, statedb.TypeTxSelector, 0)
if err != nil {
panic(err)

+ 3
- 0
batchbuilder/batchbuilder_test.go

@ -2,6 +2,7 @@ package batchbuilder
import (
"io/ioutil"
"os"
"testing"
"github.com/hermeznetwork/hermez-node/db/statedb"
@ -12,12 +13,14 @@ import (
func TestBatchBuilder(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
synchDB, err := statedb.NewStateDB(dir, statedb.TypeBatchBuilder, 0)
assert.Nil(t, err)
bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(bbDir))
_, err = NewBatchBuilder(bbDir, synchDB, nil, 0, 32)
assert.Nil(t, err)
}

+ 3
- 0
coordinator/coordinator_test.go

@ -25,6 +25,7 @@ func newTestModules(t *testing.T) (*txselector.TxSelector, *batchbuilder.BatchBu
synchDBPath, err := ioutil.TempDir("", "tmpSynchDB")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(synchDBPath))
synchSdb, err := statedb.NewStateDB(synchDBPath, statedb.TypeSynchronizer, nLevels)
assert.Nil(t, err)
@ -44,11 +45,13 @@ func newTestModules(t *testing.T) (*txselector.TxSelector, *batchbuilder.BatchBu
txselDir, err := ioutil.TempDir("", "tmpTxSelDB")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(txselDir))
txsel, err := txselector.NewTxSelector(txselDir, synchSdb, l2DB, 10, 10, 10)
assert.Nil(t, err)
bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(bbDir))
bb, err := batchbuilder.NewBatchBuilder(bbDir, synchSdb, nil, 0, uint64(nLevels))
assert.Nil(t, err)

+ 7
- 0
db/statedb/statedb_test.go

@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"math/big"
"os"
"testing"
ethCrypto "github.com/ethereum/go-ethereum/crypto"
@ -37,6 +38,7 @@ func newAccount(t *testing.T, i int) *common.Account {
func TestNewStateDBIntermediateState(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeTxSelector, 0)
assert.Nil(t, err)
@ -118,6 +120,7 @@ func TestNewStateDBIntermediateState(t *testing.T) {
func TestStateDBWithoutMT(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeTxSelector, 0)
assert.Nil(t, err)
@ -171,6 +174,7 @@ func TestStateDBWithoutMT(t *testing.T) {
func TestStateDBWithMT(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeSynchronizer, 32)
assert.Nil(t, err)
@ -222,6 +226,7 @@ func TestStateDBWithMT(t *testing.T) {
func TestCheckpoints(t *testing.T) {
dir, err := ioutil.TempDir("", "sdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeSynchronizer, 32)
assert.Nil(t, err)
@ -289,6 +294,7 @@ func TestCheckpoints(t *testing.T) {
// Create a LocalStateDB from the initial StateDB
dirLocal, err := ioutil.TempDir("", "ldb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dirLocal))
ldb, err := NewLocalStateDB(dirLocal, sdb, TypeBatchBuilder, 32)
assert.Nil(t, err)
@ -309,6 +315,7 @@ func TestCheckpoints(t *testing.T) {
// Create a 2nd LocalStateDB from the initial StateDB
dirLocal2, err := ioutil.TempDir("", "ldb2")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dirLocal2))
ldb2, err := NewLocalStateDB(dirLocal2, sdb, TypeBatchBuilder, 32)
assert.Nil(t, err)

+ 4
- 0
db/statedb/txprocessors_test.go

@ -2,6 +2,7 @@ package statedb
import (
"io/ioutil"
"os"
"testing"
"github.com/hermeznetwork/hermez-node/common"
@ -16,6 +17,7 @@ func TestProcessTxsSynchronizer(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeSynchronizer, 32)
assert.Nil(t, err)
@ -72,6 +74,7 @@ WIP
func TestProcessTxsBatchBuilder(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeBatchBuilder, 32)
assert.Nil(t, err)
@ -121,6 +124,7 @@ func TestProcessTxsBatchBuilder(t *testing.T) {
func TestZKInputsGeneration(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeBatchBuilder, 32)
assert.Nil(t, err)

+ 2
- 0
db/statedb/utils_test.go

@ -3,6 +3,7 @@ package statedb
import (
"io/ioutil"
"math/big"
"os"
"testing"
ethCommon "github.com/ethereum/go-ethereum/common"
@ -15,6 +16,7 @@ import (
func TestGetIdx(t *testing.T) {
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := NewStateDB(dir, TypeTxSelector, 0)
assert.Nil(t, err)

+ 5
- 0
eth/main_test.go

@ -115,6 +115,11 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
panic(err)
}
}()
ks = keystore.NewKeyStore(dir, keystore.LightScryptN, keystore.LightScryptP)
// Load ethereum accounts from private keys

+ 1
- 0
synchronizer/synchronizer_test.go

@ -29,6 +29,7 @@ func TestSync(t *testing.T) {
// Int State DB
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
stateDB, err := statedb.NewStateDB(dir, statedb.TypeSynchronizer, 32)
assert.Nil(t, err)

+ 2
- 0
txselector/txselector_test.go

@ -10,11 +10,13 @@ func initTest(t *testing.T, testSet string, maxL1UserTxs, maxL1OperatorTxs, maxT
dir, err := ioutil.TempDir("", "tmpdb")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
sdb, err := statedb.NewStateDB(dir, statedb.TypeTxSelector, 0)
require.Nil(t, err)
txselDir, err := ioutil.TempDir("", "tmpTxSelDB")
require.Nil(t, err)
defer assert.Nil(t, os.RemoveAll(dir))
txsel, err := NewTxSelector(txselDir, sdb, l2DB, maxL1UserTxs, maxL1OperatorTxs, maxTxs)
require.Nil(t, err)

Loading…
Cancel
Save