Fix assertion errors
This commit is contained in:
parent
de0954a449
commit
d2144cad4b
@ -107,7 +107,7 @@ func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_helpers.ExpectEqual(t, tx.(*file.BatchTx).BlockNumber, testBlock.Number().Uint64())
|
require.Equal(t, testBlock.Number().String(), tx.(*file.BatchTx).BlockNumber)
|
||||||
|
|
||||||
connStr := postgres.DefaultConfig.DbConnectionString()
|
connStr := postgres.DefaultConfig.DbConnectionString()
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_helpers.ExpectEqual(t, tx.(*sql.BatchTx).BlockNumber, testBlock.Number().Uint64())
|
require.Equal(t, testBlock.Number().String(), tx.(*sql.BatchTx).BlockNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tearDown(t *testing.T) {
|
func tearDown(t *testing.T) {
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v4/pgxpool"
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -69,7 +69,7 @@ func TestPostgresPGX(t *testing.T) {
|
|||||||
|
|
||||||
bi := new(big.Int)
|
bi := new(big.Int)
|
||||||
bi.SetString("34940183920000000000", 10)
|
bi.SetString("34940183920000000000", 10)
|
||||||
test_helpers.ExpectEqual(t, bi.String(), "34940183920000000000")
|
require.Equal(t, "34940183920000000000", bi.String())
|
||||||
|
|
||||||
defer dbPool.Exec(ctx, `DROP TABLE IF EXISTS example`)
|
defer dbPool.Exec(ctx, `DROP TABLE IF EXISTS example`)
|
||||||
_, err = dbPool.Exec(ctx, "CREATE TABLE example ( id INTEGER, data NUMERIC )")
|
_, err = dbPool.Exec(ctx, "CREATE TABLE example ( id INTEGER, data NUMERIC )")
|
||||||
@ -77,7 +77,7 @@ func TestPostgresPGX(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStatement := `
|
sqlStatement := `
|
||||||
INSERT INTO example (id, data)
|
INSERT INTO example (id, data)
|
||||||
VALUES (1, cast($1 AS NUMERIC))`
|
VALUES (1, cast($1 AS NUMERIC))`
|
||||||
_, err = dbPool.Exec(ctx, sqlStatement, bi.String())
|
_, err = dbPool.Exec(ctx, sqlStatement, bi.String())
|
||||||
@ -91,10 +91,10 @@ func TestPostgresPGX(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_helpers.ExpectEqual(t, data, bi.String())
|
require.Equal(t, data, bi.String())
|
||||||
actual := new(big.Int)
|
actual := new(big.Int)
|
||||||
actual.SetString(data, 10)
|
actual.SetString(data, 10)
|
||||||
test_helpers.ExpectEqual(t, actual, bi)
|
require.Equal(t, bi, actual)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("throws error when can't connect to the database", func(t *testing.T) {
|
t.Run("throws error when can't connect to the database", func(t *testing.T) {
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPostgresSQLX(t *testing.T) {
|
func TestPostgresSQLX(t *testing.T) {
|
||||||
@ -67,7 +67,7 @@ func TestPostgresSQLX(t *testing.T) {
|
|||||||
|
|
||||||
bi := new(big.Int)
|
bi := new(big.Int)
|
||||||
bi.SetString("34940183920000000000", 10)
|
bi.SetString("34940183920000000000", 10)
|
||||||
test_helpers.ExpectEqual(t, bi.String(), "34940183920000000000")
|
require.Equal(t, "34940183920000000000", bi.String())
|
||||||
|
|
||||||
defer db.Exec(`DROP TABLE IF EXISTS example`)
|
defer db.Exec(`DROP TABLE IF EXISTS example`)
|
||||||
_, err = db.Exec("CREATE TABLE example ( id INTEGER, data NUMERIC )")
|
_, err = db.Exec("CREATE TABLE example ( id INTEGER, data NUMERIC )")
|
||||||
@ -75,7 +75,7 @@ func TestPostgresSQLX(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStatement := `
|
sqlStatement := `
|
||||||
INSERT INTO example (id, data)
|
INSERT INTO example (id, data)
|
||||||
VALUES (1, cast($1 AS NUMERIC))`
|
VALUES (1, cast($1 AS NUMERIC))`
|
||||||
_, err = db.Exec(sqlStatement, bi.String())
|
_, err = db.Exec(sqlStatement, bi.String())
|
||||||
@ -89,10 +89,10 @@ func TestPostgresSQLX(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_helpers.ExpectEqual(t, data, bi.String())
|
require.Equal(t, data, bi.String())
|
||||||
actual := new(big.Int)
|
actual := new(big.Int)
|
||||||
actual.SetString(data, 10)
|
actual.SetString(data, 10)
|
||||||
test_helpers.ExpectEqual(t, actual, bi)
|
require.Equal(t, bi, actual)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("throws error when can't connect to the database", func(t *testing.T) {
|
t.Run("throws error when can't connect to the database", func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user