Commit 6f6a308c authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4992 from ethereum-optimism/aj/regolith-e2e-test

op-e2e: Update TestCrossLayerUser test to check deposits and tx work with and without regolith
parents 0937f338 646d0118
......@@ -155,3 +155,11 @@ func (s *L2Sequencer) ActBuildToL1HeadExclUnsafe(t Testing) {
s.ActL2EndBlock(t)
}
}
func (s *L2Sequencer) ActBuildL2ToRegolith(t Testing) {
require.NotNil(t, s.rollupCfg.RegolithTime, "cannot activate Regolith when it is not scheduled")
for s.L2Unsafe().Time < *s.rollupCfg.RegolithTime {
s.ActL2StartBlock(t)
s.ActL2EndBlock(t)
}
}
......@@ -4,6 +4,7 @@ import (
"math/rand"
"testing"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
......@@ -12,7 +13,13 @@ import (
"github.com/ethereum-optimism/optimism/op-node/testlog"
)
// TestCrossLayerUser tests that common actions of the CrossLayerUser actor work:
type regolithScheduledTest struct {
name string
regolithTime *hexutil.Uint64
activateRegolith bool
}
// TestCrossLayerUser tests that common actions of the CrossLayerUser actor work in various regolith configurations:
// - transact on L1
// - transact on L2
// - deposit on L1
......@@ -20,9 +27,28 @@ import (
// - prove tx on L1
// - wait 1 week + 1 second
// - finalize withdrawal on L1
func TestCrossLayerUser(gt *testing.T) {
func TestCrossLayerUser(t *testing.T) {
zeroTime := hexutil.Uint64(0)
futureTime := hexutil.Uint64(20)
farFutureTime := hexutil.Uint64(2000)
tests := []regolithScheduledTest{
{name: "NoRegolith", regolithTime: nil, activateRegolith: false},
{name: "NotYetRegolith", regolithTime: &farFutureTime, activateRegolith: false},
{name: "RegolithAtGenesis", regolithTime: &zeroTime, activateRegolith: true},
{name: "RegolithAfterGenesis", regolithTime: &futureTime, activateRegolith: true},
}
for _, test := range tests {
test := test // Use a fixed reference as the tests run in parallel
t.Run(test.name, func(gt *testing.T) {
runCrossLayerUserTest(gt, test)
})
}
}
func runCrossLayerUserTest(gt *testing.T, test regolithScheduledTest) {
t := NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams)
dp.DeployConfig.L2GenesisRegolithTimeOffset = test.regolithTime
sd := e2eutils.Setup(t, dp, defaultAlloc)
log := testlog.Logger(t, log.LvlDebug)
......@@ -64,6 +90,21 @@ func TestCrossLayerUser(gt *testing.T) {
alice.L1.SetUserEnv(l1UserEnv)
alice.L2.SetUserEnv(l2UserEnv)
// Build at least one l2 block so we have an unsafe head with a deposit info tx (genesis block doesn't)
seq.ActL2StartBlock(t)
seq.ActL2EndBlock(t)
if test.activateRegolith {
// advance L2 enough to activate regolith fork
seq.ActBuildL2ToRegolith(t)
}
// Check Regolith is active or not by confirming the system info tx is not a system tx
infoTx, err := l2Cl.TransactionInBlock(t.Ctx(), seq.L2Unsafe().Hash, 0)
require.NoError(t, err)
require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled
require.Equal(t, !test.activateRegolith, infoTx.IsSystemTx())
// regular L2 tx, in new L2 block
alice.L2.ActResetTxOpts(t)
alice.L2.ActSetTxToAddr(&dp.Addresses.Bob)(t)
......@@ -158,4 +199,11 @@ func TestCrossLayerUser(gt *testing.T) {
miner.ActL1EndBlock(t)
// check withdrawal succeeded
alice.L1.ActCheckReceiptStatusOfLastTx(true)(t)
// Check Regolith wasn't activated during the test unintentionally
infoTx, err = l2Cl.TransactionInBlock(t.Ctx(), seq.L2Unsafe().Hash, 0)
require.NoError(t, err)
require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled
require.Equal(t, !test.activateRegolith, infoTx.IsSystemTx())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment