From d2144cad4bfc96d6d04a5ae9f1090d5b058f2eb0 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Tue, 19 Apr 2022 10:40:30 +0530 Subject: [PATCH] Fix assertion errors --- .../database/file/mainnet_tests/indexer_test.go | 2 +- .../indexer/database/sql/mainnet_tests/indexer_test.go | 2 +- statediff/indexer/database/sql/postgres/pgx_test.go | 10 +++++----- statediff/indexer/database/sql/postgres/sqlx_test.go | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/statediff/indexer/database/file/mainnet_tests/indexer_test.go b/statediff/indexer/database/file/mainnet_tests/indexer_test.go index b297b82d1450..0fbb27555da6 100644 --- a/statediff/indexer/database/file/mainnet_tests/indexer_test.go +++ b/statediff/indexer/database/file/mainnet_tests/indexer_test.go @@ -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() diff --git a/statediff/indexer/database/sql/mainnet_tests/indexer_test.go b/statediff/indexer/database/sql/mainnet_tests/indexer_test.go index 158009ac944d..55f535aa8486 100644 --- a/statediff/indexer/database/sql/mainnet_tests/indexer_test.go +++ b/statediff/indexer/database/sql/mainnet_tests/indexer_test.go @@ -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) { diff --git a/statediff/indexer/database/sql/postgres/pgx_test.go b/statediff/indexer/database/sql/postgres/pgx_test.go index 64616e356a96..043112e8d0a8 100644 --- a/statediff/indexer/database/sql/postgres/pgx_test.go +++ b/statediff/indexer/database/sql/postgres/pgx_test.go @@ -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 ( @@ -69,7 +69,7 @@ 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 )") @@ -77,7 +77,7 @@ func TestPostgresPGX(t *testing.T) { t.Fatal(err) } - sqlStatement := ` + sqlStatement := ` INSERT INTO example (id, data) VALUES (1, cast($1 AS NUMERIC))` _, err = dbPool.Exec(ctx, sqlStatement, bi.String()) @@ -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) { diff --git a/statediff/indexer/database/sql/postgres/sqlx_test.go b/statediff/indexer/database/sql/postgres/sqlx_test.go index 03f24e9f5548..40b9763146ee 100644 --- a/statediff/indexer/database/sql/postgres/sqlx_test.go +++ b/statediff/indexer/database/sql/postgres/sqlx_test.go @@ -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) { @@ -67,7 +67,7 @@ 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 )") @@ -75,7 +75,7 @@ func TestPostgresSQLX(t *testing.T) { t.Fatal(err) } - sqlStatement := ` + sqlStatement := ` INSERT INTO example (id, data) VALUES (1, cast($1 AS NUMERIC))` _, err = db.Exec(sqlStatement, bi.String()) @@ -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) {