Skip to content

Commit

Permalink
use memory for sqlite on the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Sep 5, 2024
1 parent d0b035d commit c245cfd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bridgesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func newSimulatedClient(t *testing.T, auth *bind.TransactOpts) (

func TestBridgeEventE2E(t *testing.T) {
ctx := context.Background()
dbPathSyncer := path.Join(t.TempDir(), "tmp.sqlite")
dbPathSyncer := path.Join(t.TempDir(), "file::memory:?cache=shared")
dbPathReorg := t.TempDir()
privateKey, err := crypto.GenerateKey()
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion bridgesync/migrations/bridgesync0001_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func Test001(t *testing.T) {
dbPath := path.Join(t.TempDir(), "tmp.db")
dbPath := path.Join(t.TempDir(), "file::memory:?cache=shared")

err := RunMigrations(dbPath)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion bridgesync/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

func TestProceessor(t *testing.T) {
path := path.Join(t.TempDir(), "tmp.sqlite")
path := path.Join(t.TempDir(), "file::memory:?cache=shared")
log.Debugf("sqlite path: %s", path)
err := migrationsBridge.RunMigrations(path)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion claimsponsor/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestE2EL1toEVML2(t *testing.T) {
// start other needed components
ctx := context.Background()
env := helpers.SetupAggoracleWithEVMChain(t)
dbPathBridgeSyncL1 := path.Join(t.TempDir(), "tmp.sqlite")
dbPathBridgeSyncL1 := path.Join(t.TempDir(), "file::memory:?cache=shared")
testClient := helpers.TestClient{ClientRenamed: env.L1Client.Client()}
bridgeSyncL1, err := bridgesync.NewL1(ctx, dbPathBridgeSyncL1, env.BridgeL1Addr, 10, etherman.LatestBlock, env.ReorgDetector, testClient, 0, time.Millisecond*10, 0, 0)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions l1bridge2infoindexsync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func newSimulatedClient(authDeployer, authCaller *bind.TransactOpts) (

func TestE2E(t *testing.T) {
ctx := context.Background()
dbPathBridgeSync := path.Join(t.TempDir(), "tmp.sqlite")
dbPathL1Sync := path.Join(t.TempDir(), "tmp.sqlite")
dbPathBridgeSync := path.Join(t.TempDir(), "file::memory:?cache=shared")
dbPathL1Sync := path.Join(t.TempDir(), "file::memory:?cache=shared")
dbPathReorg := t.TempDir()
dbPathL12InfoSync := t.TempDir()

Expand Down
4 changes: 2 additions & 2 deletions l1infotreesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func newSimulatedClient(auth *bind.TransactOpts) (

func TestE2E(t *testing.T) {
ctx := context.Background()
dbPath := path.Join(t.TempDir(), "tmp.sqlite")
dbPath := path.Join(t.TempDir(), "file::memory:?cache=shared")
privateKey, err := crypto.GenerateKey()
require.NoError(t, err)
auth, err := bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1337))
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestStressAndReorgs(t *testing.T) {
)

ctx := context.Background()
dbPathSyncer := path.Join(t.TempDir(), "tmp.sqlite")
dbPathSyncer := path.Join(t.TempDir(), "file::memory:?cache=shared")
dbPathReorg := t.TempDir()
privateKey, err := crypto.GenerateKey()
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/aggoracle_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func CommonSetup(t *testing.T) (
reorg, err := reorgdetector.New(l1Client.Client(), reorgdetector.Config{DBPath: dbPathReorgDetector})
require.NoError(t, err)
// Syncer
dbPathSyncer := path.Join(t.TempDir(), "tmp.sqlite")
dbPathSyncer := path.Join(t.TempDir(), "file::memory:?cache=shared")
syncer, err := l1infotreesync.New(ctx, dbPathSyncer, gerL1Addr, common.Address{}, 10, etherman.LatestBlock, reorg, l1Client.Client(), time.Millisecond, 0, 100*time.Millisecond, 3)
require.NoError(t, err)
go syncer.Start(ctx)
Expand Down
6 changes: 4 additions & 2 deletions tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ func TestMTAddLeaf(t *testing.T) {

for ti, testVector := range mtTestVectors {
t.Run(fmt.Sprintf("Test vector %d", ti), func(t *testing.T) {
dbPath := path.Join(t.TempDir(), "tmp.db")
dbPath := path.Join(t.TempDir(), "file::memory:?cache=shared")
log.Debug("DB created at: ", dbPath)
err := migrations.RunMigrations(dbPath)
require.NoError(t, err)
db, err := db.NewSQLiteDB(dbPath)
require.NoError(t, err)
_, err = db.Exec(`select * from root`)
require.NoError(t, err)
merkletree := tree.NewAppendOnlyTree(db, "")

// Add exisiting leaves
Expand Down Expand Up @@ -82,7 +84,7 @@ func TestMTGetProof(t *testing.T) {

for ti, testVector := range mtTestVectors {
t.Run(fmt.Sprintf("Test vector %d", ti), func(t *testing.T) {
dbPath := path.Join(t.TempDir(), "tmp.db")
dbPath := path.Join(t.TempDir(), "file::memory:?cache=shared")
err := migrations.RunMigrations(dbPath)
require.NoError(t, err)
db, err := db.NewSQLiteDB(dbPath)
Expand Down

0 comments on commit c245cfd

Please sign in to comment.