Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
i-norden committed Mar 24, 2022
1 parent 7bc4c75 commit 1e64f48
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 265 deletions.
11 changes: 5 additions & 6 deletions statediff/indexer/database/file/indexer_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
)

var (
Expand Down Expand Up @@ -71,7 +70,7 @@ func setupLegacy(t *testing.T) {
require.NoError(t, err)
}

test_helpers.ExpectEqual(t, tx.(*file.BatchTx).BlockNumber, legacyData.BlockNumber.Uint64())
require.Equal(t, legacyData.BlockNumber.String(), tx.(*file.BatchTx).BlockNumber)

connStr := postgres.DefaultConfig.DbConnectionString()

Expand Down Expand Up @@ -123,10 +122,10 @@ func TestFileIndexerLegacy(t *testing.T) {
err = sqlxdb.QueryRowx(pgStr, legacyData.BlockNumber.Uint64()).StructScan(header)
require.NoError(t, err)

test_helpers.ExpectEqual(t, header.CID, legacyHeaderCID.String())
test_helpers.ExpectEqual(t, header.TD, legacyData.MockBlock.Difficulty().String())
test_helpers.ExpectEqual(t, header.Reward, "5000000000000011250")
test_helpers.ExpectEqual(t, header.Coinbase, legacyData.MockBlock.Coinbase().String())
require.Equal(t, legacyHeaderCID.String(), header.CID)
require.Equal(t, legacyData.MockBlock.Difficulty().String(), header.TD)
require.Equal(t, "5000000000000011250", header.Reward)
require.Equal(t, legacyData.MockBlock.Coinbase().String(), header.Coinbase)
require.Nil(t, legacyData.MockHeader.BaseFee)
})
}
152 changes: 80 additions & 72 deletions statediff/indexer/database/file/indexer_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion statediff/indexer/database/sql/indexer_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
err error
ind interfaces.StateDiffIndexer
ipfsPgGet = `SELECT data FROM public.blocks
WHERE key = $1`
WHERE key = $1 AND block_number = $2`
tx1, tx2, tx3, tx4, tx5, rct1, rct2, rct3, rct4, rct5 []byte
mockBlock *types.Block
headerCID, trx1CID, trx2CID, trx3CID, trx4CID, trx5CID cid.Cid
Expand Down
11 changes: 5 additions & 6 deletions statediff/indexer/database/sql/pgx_indexer_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
)

func setupLegacyPGX(t *testing.T) {
Expand Down Expand Up @@ -56,7 +55,7 @@ func setupLegacyPGX(t *testing.T) {
require.NoError(t, err)
}

test_helpers.ExpectEqual(t, tx.(*sql.BatchTx).BlockNumber, legacyData.BlockNumber.Uint64())
require.Equal(t, legacyData.BlockNumber.String(), tx.(*sql.BatchTx).BlockNumber)
}

func TestLegacyPGXIndexer(t *testing.T) {
Expand All @@ -81,10 +80,10 @@ func TestLegacyPGXIndexer(t *testing.T) {
&header.CID, &header.TD, &header.Reward, &header.BlockHash, &header.Coinbase)
require.NoError(t, err)

test_helpers.ExpectEqual(t, header.CID, legacyHeaderCID.String())
test_helpers.ExpectEqual(t, header.TD, legacyData.MockBlock.Difficulty().String())
test_helpers.ExpectEqual(t, header.Reward, "5000000000000011250")
test_helpers.ExpectEqual(t, header.Coinbase, legacyData.MockHeader.Coinbase.String())
require.Equal(t, legacyHeaderCID.String(), header.CID)
require.Equal(t, legacyData.MockBlock.Difficulty().String(), header.TD)
require.Equal(t, "5000000000000011250", header.Reward)
require.Equal(t, legacyData.MockHeader.Coinbase.String(), header.Coinbase)
require.Nil(t, legacyData.MockHeader.BaseFee)
})
}
Loading

0 comments on commit 1e64f48

Please sign in to comment.