Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Sep 13, 2024
1 parent 1848eca commit 751543d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions l1infotreesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestFinalised(t *testing.T) {

func TestWithReorgs(t *testing.T) {
ctx := context.Background()
dbPathSyncer := t.TempDir()
dbPathSyncer := path.Join(t.TempDir(), "file::memory:?cache=shared")
dbPathReorg := t.TempDir()
privateKey, err := crypto.GenerateKey()
require.NoError(t, err)
Expand Down Expand Up @@ -218,44 +218,44 @@ func TestWithReorgs(t *testing.T) {
require.NoError(t, err)
actualRollupExitRoot, err := syncer.GetLastRollupExitRoot(ctx)
require.NoError(t, err)
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot)
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot)
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)

// Assert L1 Info tree root
expectedL1InfoRoot, err := gerSc.GetRoot(&bind.CallOpts{Pending: false})
require.NoError(t, err)
expectedGER, err := gerSc.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false})
require.NoError(t, err)
index, actualL1InfoRoot, err := syncer.GetLastL1InfoTreeRootAndIndex(ctx)
actualL1InfoRoot, err := syncer.GetLastL1InfoTreeRoot(ctx)
require.NoError(t, err)
info, err := syncer.GetInfoByIndex(ctx, actualL1InfoRoot.Index)
require.NoError(t, err)
info, err := syncer.GetInfoByIndex(ctx, index)
require.NoError(t, err, fmt.Sprintf("index: %d", index))

require.Equal(t, common.Hash(expectedL1InfoRoot), actualL1InfoRoot)
require.Equal(t, common.Hash(expectedL1InfoRoot), actualL1InfoRoot.Hash)
require.Equal(t, common.Hash(expectedGER), info.GlobalExitRoot, fmt.Sprintf("%+v", info))

// Forking from block 3
err = client.Fork(reorgFrom)
require.NoError(t, err)

// Block 4, 5, 6 after the fork
commitBlocks(t, client, 3, time.Millisecond*100)
commitBlocks(t, client, 3, time.Millisecond*500)

// Make sure syncer is up to date
waitForSyncerToCatchUp(ctx, t, syncer, client)

// Assert rollup exit root after the fork - should be zero since there are no events in the block after the fork
expectedRollupExitRoot, err = verifySC.GetRollupExitRoot(&bind.CallOpts{Pending: false})
require.NoError(t, err)
actualRollupExitRoot, err = syncer.GetLastRollupExitRoot(ctx) // TODO: <- Fails
require.NoError(t, err)
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot) // TODO: <- Fails
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot)
actualRollupExitRoot, err = syncer.GetLastRollupExitRoot(ctx)
require.ErrorContains(t, err, "not found") // rollup exit tree reorged, it does not have any exits in it
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)

// Forking from block 3 again
err = client.Fork(reorgFrom)
require.NoError(t, err)
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 500)

// create some events and update the trees
updateL1InfoTreeAndRollupExitTree(2, 1)
Expand All @@ -271,8 +271,8 @@ func TestWithReorgs(t *testing.T) {
require.NoError(t, err)
actualRollupExitRoot, err = syncer.GetLastRollupExitRoot(ctx)
require.NoError(t, err)
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot)
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot)
t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)
require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash)
}

func TestStressAndReorgs(t *testing.T) {
Expand Down

0 comments on commit 751543d

Please sign in to comment.