Index blob hashes #27

Merged
roysc merged 6 commits from index-blob-hashes into main 2024-08-01 02:50:30 +00:00
Showing only changes of commit 115b3c779e - Show all commits

View File

@ -131,6 +131,7 @@ func DoTestPublishAndIndexTransactionIPLDs(t *testing.T, db sql.Database) {
} }
txTypeAndValueStr := `SELECT tx_type, CAST(value as TEXT) FROM eth.transaction_cids WHERE cid = $1` txTypeAndValueStr := `SELECT tx_type, CAST(value as TEXT) FROM eth.transaction_cids WHERE cid = $1`
txBlobHashQuery := `SELECT blob_hash FROM eth.blob_hashes WHERE tx_hash = $1` txBlobHashQuery := `SELECT blob_hash FROM eth.blob_hashes WHERE tx_hash = $1`
txBlobIndexQuery := `SELECT index FROM eth.blob_hashes WHERE tx_hash = $1`
switch c { switch c {
case txCIDs[0].String(): case txCIDs[0].String():
require.Equal(t, encodedTxs[0], data) require.Equal(t, encodedTxs[0], data)
@ -206,12 +207,19 @@ func DoTestPublishAndIndexTransactionIPLDs(t *testing.T, db sql.Database) {
} }
require.Equal(t, types.BlobTxType, txRes.TxType) require.Equal(t, types.BlobTxType, txRes.TxType)
require.Equal(t, transactions[5].Value().String(), txRes.Value) require.Equal(t, transactions[5].Value().String(), txRes.Value)
var txBlobHashes []common.Hash var txBlobHashes []common.Hash
var txBlobIndices []uint64
err = db.Select(context.Background(), &txBlobHashes, txBlobHashQuery, transactions[5].Hash().String()) err = db.Select(context.Background(), &txBlobHashes, txBlobHashQuery, transactions[5].Hash().String())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
require.Equal(t, transactions[5].BlobHashes(), txBlobHashes) require.Equal(t, transactions[5].BlobHashes(), txBlobHashes)
err = db.Select(context.Background(), &txBlobIndices, txBlobIndexQuery, transactions[5].Hash().String())
if err != nil {
t.Fatal(err)
}
require.Equal(t, []uint64{0, 1}, txBlobIndices)
} }
} }
} }