forked from okx/xlayer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tracer to work by block stateroot instead of by tx (0xPolygonHerm…
- Loading branch information
Showing
4 changed files
with
80 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- +migrate Up | ||
CREATE INDEX IF NOT EXISTS idx_receipt_tx_index ON state.receipt (block_num, tx_index); | ||
|
||
-- +migrate Down | ||
DROP INDEX IF EXISTS state.idx_receipt_tx_index; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package migrations_test | ||
|
||
import ( | ||
"database/sql" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// this migration changes length of the token name | ||
type migrationTest0015 struct{} | ||
|
||
func (m migrationTest0015) InsertData(db *sql.DB) error { | ||
return nil | ||
} | ||
|
||
func (m migrationTest0015) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { | ||
indexes := []string{ | ||
"idx_receipt_tx_index", | ||
} | ||
// Check indexes adding | ||
for _, idx := range indexes { | ||
// getIndex | ||
const getIndex = `SELECT count(*) FROM pg_indexes WHERE indexname = $1;` | ||
row := db.QueryRow(getIndex, idx) | ||
var result int | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 1, result) | ||
} | ||
} | ||
|
||
func (m migrationTest0015) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { | ||
indexes := []string{ | ||
"idx_receipt_tx_index", | ||
} | ||
// Check indexes removing | ||
for _, idx := range indexes { | ||
// getIndex | ||
const getIndex = `SELECT count(*) FROM pg_indexes WHERE indexname = $1;` | ||
row := db.QueryRow(getIndex, idx) | ||
var result int | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 0, result) | ||
} | ||
} | ||
|
||
func TestMigration0015(t *testing.T) { | ||
runMigrationTest(t, 15, migrationTest0015{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters