b241bf05eb
* Add command to take an in-place snapshot * Add test data for in place snapshot unit test * Implement unit test for inplace snapshot * Add check for storage IPLD * Run unit tests sequentially * Add github workflow for unit test * Add missing checks for state and storage cid fields * Add more storage nodes to test * Update ipld-eth-db version for tests * Add comments for inplace snapshot test data * Add in-place snapshot cmd in readme * Implement defer pattern for db transaction * Log transaction commit or rollback error Co-authored-by: nabarun <nabarun@deepstacksoft.com>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package test
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
|
ethnode "github.com/ethereum/go-ethereum/statediff/indexer/node"
|
|
)
|
|
|
|
var (
|
|
DefaultNodeInfo = ethnode.Info{
|
|
ID: "test_nodeid",
|
|
ClientName: "test_client",
|
|
GenesisBlock: "TEST_GENESIS",
|
|
NetworkID: "test_network",
|
|
ChainID: 0,
|
|
}
|
|
DefaultPgConfig = postgres.Config{
|
|
Hostname: "localhost",
|
|
Port: 8077,
|
|
DatabaseName: "vulcanize_testing",
|
|
Username: "vdbm",
|
|
Password: "password",
|
|
|
|
MaxIdle: 0,
|
|
MaxConnLifetime: 0,
|
|
MaxConns: 4,
|
|
}
|
|
)
|
|
|
|
func NeedsDB(t *testing.T) {
|
|
t.Helper()
|
|
if os.Getenv("TEST_WITH_DB") == "" {
|
|
t.Skip("set TEST_WITH_DB to enable test")
|
|
}
|
|
}
|
|
|
|
func NoError(t *testing.T, err error) {
|
|
t.Helper()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// ExpectEqual asserts the provided interfaces are deep equal
|
|
func ExpectEqual(t *testing.T, want, got interface{}) {
|
|
if !reflect.DeepEqual(want, got) {
|
|
t.Fatalf("Values not equal:\nExpected:\t%v\nActual:\t\t%v", want, got)
|
|
}
|
|
}
|
|
|
|
func ExpectEqualBytes(t *testing.T, want, got []byte) {
|
|
if !bytes.Equal(want, got) {
|
|
t.Fatalf("Bytes not equal:\nExpected:\t%v\nActual:\t\t%v", want, got)
|
|
}
|
|
}
|