Skip to content

Commit

Permalink
Implement CSV file for watched addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
nikugogoi committed Jun 27, 2022
1 parent 0da954b commit 09af53b
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 193 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.2'
version: "3.2"

services:
migrations:
Expand Down
2 changes: 1 addition & 1 deletion statediff/indexer/database/file/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var TestConfig = Config{
Mode: CSV,
OutputDir: "./statediffing_test",
FilePath: "./statediffing_test_file.sql",
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.sql",
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.csv",
NodeInfo: node.Info{
GenesisBlock: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
NetworkID: "1",
Expand Down
11 changes: 10 additions & 1 deletion statediff/indexer/database/file/csv_indexer_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ 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/types"
)

const dbDirectory = "/file"
const pgCopyStatement = `COPY %s FROM '%s' CSV`

func setupCSVLegacy(t *testing.T) {
mockLegacyBlock = legacyData.MockBlock
Expand Down Expand Up @@ -81,7 +83,6 @@ func setupCSVLegacy(t *testing.T) {
}

func dumpCSVFileData(t *testing.T) {
pgCopyStatement := `COPY %s FROM '%s' CSV`
outputDir := filepath.Join(dbDirectory, file.TestConfig.OutputDir)

for _, tbl := range file.Tables {
Expand All @@ -102,6 +103,14 @@ func dumpCSVFileData(t *testing.T) {
}
}

func dumpWatchedAddressesCSVFileData(t *testing.T) {
outputFilePath := filepath.Join(dbDirectory, file.TestConfig.WatchedAddressesFilePath)
stm := fmt.Sprintf(pgCopyStatement, types.TableWatchedAddresses.Name, outputFilePath)

_, err = sqlxdb.Exec(stm)
require.NoError(t, err)
}

func tearDownCSV(t *testing.T) {
file.TearDownDB(t, sqlxdb)

Expand Down
Loading

0 comments on commit 09af53b

Please sign in to comment.