Commit f2ffb97d authored by Michael de Hoog's avatar Michael de Hoog

Add E2E test

parent 97c359a3
......@@ -79,7 +79,7 @@ type CLIConfig struct {
PollInterval time.Duration
// MaxPendingTransactions is the maximum number of concurrent pending
// transactions sent to the transaction manager.
// transactions sent to the transaction manager (0 == no limit).
MaxPendingTransactions uint64
// MaxL1TxSize is the maximum size of a batch tx submitted to L1.
......
......@@ -180,9 +180,10 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
"batcher": testlog.Logger(t, log.LvlInfo).New("role", "batcher"),
"proposer": testlog.Logger(t, log.LvlCrit).New("role", "proposer"),
},
GethOptions: map[string][]GethOption{},
P2PTopology: nil, // no P2P connectivity by default
NonFinalizedProposals: false,
GethOptions: map[string][]GethOption{},
P2PTopology: nil, // no P2P connectivity by default
NonFinalizedProposals: false,
BatcherTargetL1TxSizeBytes: 100_000,
}
}
......@@ -229,6 +230,9 @@ type SystemConfig struct {
// Explicitly disable batcher, for tests that rely on unsafe L2 payloads
DisableBatcher bool
// Target L1 tx size for the batcher transactions
BatcherTargetL1TxSizeBytes uint64
}
type System struct {
......@@ -611,11 +615,11 @@ func (cfg SystemConfig) Start(_opts ...SystemConfigOption) (*System, error) {
L1EthRpc: sys.Nodes["l1"].WSEndpoint(),
L2EthRpc: sys.Nodes["sequencer"].WSEndpoint(),
RollupRpc: sys.RollupNodes["sequencer"].HTTPEndpoint(),
MaxPendingTransactions: 1,
MaxPendingTransactions: 0,
MaxChannelDuration: 1,
MaxL1TxSize: 120_000,
CompressorConfig: compressor.CLIConfig{
TargetL1TxSizeBytes: 100_000,
TargetL1TxSizeBytes: cfg.BatcherTargetL1TxSizeBytes,
TargetNumFrames: 1,
ApproxComprRatio: 0.4,
},
......
......@@ -1370,6 +1370,49 @@ func TestStopStartBatcher(t *testing.T) {
require.Greater(t, newSeqStatus.SafeL2.Number, seqStatus.SafeL2.Number, "Safe chain did not advance after batcher was restarted")
}
func TestBatcherMultiTx(t *testing.T) {
InitParallel(t)
cfg := DefaultSystemConfig(t)
cfg.BatcherTargetL1TxSizeBytes = 2 // ensures that batcher txs are as small as possible
cfg.DisableBatcher = true
sys, err := cfg.Start()
require.Nil(t, err, "Error starting up system")
defer sys.Close()
l1Client := sys.Clients["l1"]
l2Seq := sys.Clients["sequencer"]
_, err = waitForBlock(big.NewInt(10), l2Seq, time.Duration(cfg.DeployConfig.L2BlockTime*15)*time.Second)
require.Nil(t, err, "Waiting for L2 blocks")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
l1Number, err := l1Client.BlockNumber(ctx)
require.Nil(t, err)
// start batch submission
err = sys.BatchSubmitter.Start()
require.Nil(t, err)
// wait for 3 L1 blocks
_, err = waitForBlock(big.NewInt(int64(l1Number)+3), l1Client, time.Duration(cfg.DeployConfig.L1BlockTime*5)*time.Second)
require.Nil(t, err, "Waiting for l1 blocks")
// count the number of transactions submitted to L1 in the last 3 blocks
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
totalTxCount := 0
for i := int64(0); i < 3; i++ {
block, err := l1Client.BlockByNumber(ctx, big.NewInt(int64(l1Number)+i+1))
require.Nil(t, err)
totalTxCount += len(block.Transactions())
}
// expect at least 10 batcher transactions, given 10 L2 blocks were generated above
require.GreaterOrEqual(t, totalTxCount, 10)
}
func safeAddBig(a *big.Int, b *big.Int) *big.Int {
return new(big.Int).Add(a, b)
}
......
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