Insert ETH as HistoryDB token

This commit is contained in:
Arnau B
2020-10-29 17:08:42 +01:00
parent 4524f7a4ea
commit cbeca0f76e
13 changed files with 145 additions and 96 deletions

View File

@@ -3,6 +3,9 @@ package test
import (
"testing"
"github.com/gobuffalo/packr/v2"
"github.com/jmoiron/sqlx"
migrate "github.com/rubenv/sql-migrate"
"github.com/stretchr/testify/assert"
)
@@ -21,3 +24,19 @@ func AssertUSD(t *testing.T, expected, actual *float64) {
}
*expected = *actual
}
// WipeDB redo all the migrations of the SQL DB (HistoryDB and L2DB),
// efectively recreating the original state
func WipeDB(db *sqlx.DB) {
migrations := &migrate.PackrMigrationSource{
Box: packr.New("hermez-db-migrations", "../db/migrations"),
}
_, err := migrate.Exec(db.DB, "postgres", migrations, migrate.Down)
if err != nil {
panic(err)
}
_, err = migrate.Exec(db.DB, "postgres", migrations, migrate.Up)
if err != nil {
panic(err)
}
}