Skip to content

Commit

Permalink
Fix assertion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed May 11, 2022
1 parent de0954a commit d2144ca
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
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) {
Expand Down
10 changes: 5 additions & 5 deletions statediff/indexer/database/sql/postgres/pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"testing"

"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/node"
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
)

var (
Expand Down Expand Up @@ -69,15 +69,15 @@ func TestPostgresPGX(t *testing.T) {

bi := new(big.Int)
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`)
_, err = dbPool.Exec(ctx, "CREATE TABLE example ( id INTEGER, data NUMERIC )")
if err != nil {
t.Fatal(err)
}

sqlStatement := `
sqlStatement := `
INSERT INTO example (id, data)
VALUES (1, cast($1 AS NUMERIC))`
_, err = dbPool.Exec(ctx, sqlStatement, bi.String())
Expand All @@ -91,10 +91,10 @@ func TestPostgresPGX(t *testing.T) {
t.Fatal(err)
}

test_helpers.ExpectEqual(t, data, bi.String())
require.Equal(t, data, bi.String())
actual := new(big.Int)
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) {
Expand Down
10 changes: 5 additions & 5 deletions statediff/indexer/database/sql/postgres/sqlx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (

"github.com/jmoiron/sqlx"
_ "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/node"
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
)

func TestPostgresSQLX(t *testing.T) {
Expand Down Expand Up @@ -67,15 +67,15 @@ func TestPostgresSQLX(t *testing.T) {

bi := new(big.Int)
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`)
_, err = db.Exec("CREATE TABLE example ( id INTEGER, data NUMERIC )")
if err != nil {
t.Fatal(err)
}

sqlStatement := `
sqlStatement := `
INSERT INTO example (id, data)
VALUES (1, cast($1 AS NUMERIC))`
_, err = db.Exec(sqlStatement, bi.String())
Expand All @@ -89,10 +89,10 @@ func TestPostgresSQLX(t *testing.T) {
t.Fatal(err)
}

test_helpers.ExpectEqual(t, data, bi.String())
require.Equal(t, data, bi.String())
actual := new(big.Int)
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) {
Expand Down

0 comments on commit d2144ca

Please sign in to comment.