Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sync_tester_elsync

import (
"testing"

"github.com/ethereum-optimism/optimism/op-devstack/devtest"
"github.com/ethereum-optimism/optimism/op-devstack/dsl"
"github.com/ethereum-optimism/optimism/op-devstack/presets"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
)

// Validates multiple CLs can sync concurrently when backed by a single Sync Tester
// Each CL initializes its own mock EL endpoint (session) via the Sync Tester service.
func TestSyncTester_MultipleCLsSingleSyncTester(gt *testing.T) {
t := devtest.SerialT(gt)
require := t.Require()

sys := presets.NewSimpleWithSyncTester(t)

// Sanity: both CLs should advance to a small target using their respective EL backends
// L2CL: regular EL; L2CL2: SyncTester-provided EL (unique session)
target := uint64(12)
dsl.CheckAll(t,
sys.L2CL.AdvancedFn(types.LocalUnsafe, target, 60),
sys.L2CL2.AdvancedFn(types.LocalUnsafe, target, 60),
)

// Cross-check: both CLs unsafe heads must exist on the read-only EL
head1 := sys.L2CL.SyncStatus().UnsafeL2
head2 := sys.L2CL2.SyncStatus().UnsafeL2

require.GreaterOrEqual(head1.Number, target)
require.GreaterOrEqual(head2.Number, target)
require.Equal(sys.L2EL.BlockRefByNumber(head1.Number).Hash, head1.Hash)
require.Equal(sys.L2EL.BlockRefByNumber(head2.Number).Hash, head2.Hash)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package sync_tester_elsync

import (
"testing"

"github.com/ethereum-optimism/optimism/op-devstack/devtest"
"github.com/ethereum-optimism/optimism/op-devstack/presets"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
)

// Ensures a user L2 transaction appears in blocks and both CLs (one on SyncTester EL) sync past it
func TestSyncTester_UserTxIncludedAndSynced(gt *testing.T) {
t := devtest.SerialT(gt)
require := t.Require()

sys := presets.NewSimpleWithSyncTester(t)

// Fund two EOAs on L2
alice := sys.FunderL2.NewFundedEOA(eth.OneEther)
bob := sys.FunderL2.NewFundedEOA(eth.OneEther)
bobInitial := bob.GetBalance()

// Send a user transfer on L2 via sequencer path
amount := eth.OneHundredthEther
tx := alice.Transfer(bob.Address(), amount)
receipt, err := tx.Included.Eval(t.Ctx())
require.NoError(err)
require.NotNil(receipt)

// Let both CLs advance beyond the inclusion block
inclusionNum := receipt.BlockNumber.Uint64()
target := inclusionNum + 5

sys.L2CL.Reached(types.LocalUnsafe, target, 120)
sys.L2CL2.Reached(types.LocalUnsafe, target, 120)

// Verify receiver balance increased by at least the transfer amount
bob.WaitForBalance(bobInitial.Add(amount))
}