|
| 1 | +package devnet_tests |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/ethereum/go-ethereum" |
| 8 | + "github.com/stretchr/testify/require" |
| 9 | +) |
| 10 | + |
| 11 | +func TestBatcherRestart(t *testing.T) { |
| 12 | + ctx, cancel := context.WithCancel(context.Background()) |
| 13 | + defer cancel() |
| 14 | + |
| 15 | + d := NewDevnet(ctx, t) |
| 16 | + require.NoError(t, d.Up()) |
| 17 | + defer func() { |
| 18 | + require.NoError(t, d.Down()) |
| 19 | + }() |
| 20 | + |
| 21 | + // Send a transaction just to check that everything has started up ok. |
| 22 | + require.NoError(t, d.RunSimpleL2Burn()) |
| 23 | + |
| 24 | + // Shut down the batcher and have another transaction submitted while it is down. |
| 25 | + require.NoError(t, d.ServiceDown("op-batcher")) |
| 26 | + d.SleepOutageDuration() |
| 27 | + |
| 28 | + receipt, err := d.SubmitSimpleL2Burn() |
| 29 | + require.NoError(t, err) |
| 30 | + |
| 31 | + // Check that while the batcher is down, the verifier does NOT process submitted transactions. |
| 32 | + d.SleepOutageDuration() |
| 33 | + _, err = d.L2Verif.TransactionReceipt(ctx, receipt.Receipt.TxHash) |
| 34 | + require.ErrorIs(t, err, ethereum.NotFound) |
| 35 | + |
| 36 | + // Bring the batcher back up and check that it processes the transaction which was submitted |
| 37 | + // while it was down. |
| 38 | + require.NoError(t, d.ServiceUp("op-batcher")) |
| 39 | + require.NoError(t, d.VerifySimpleL2Burn(receipt)) |
| 40 | + |
| 41 | + // Submit another transaction at the end just to check that things stay working. |
| 42 | + d.SleepRecoveryDuration() |
| 43 | + require.NoError(t, d.RunSimpleL2Burn()) |
| 44 | +} |
0 commit comments