Commit 23630395 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #4281 from ethereum-optimism/clabby/indexer/two-step-withdrawals-tests

feat(indexer): Update bedrock tests for `WithdrawalProven` event
parents 07ed00ac 2cc76253
...@@ -175,6 +175,7 @@ func TestBedrockIndexer(t *testing.T) { ...@@ -175,6 +175,7 @@ func TestBedrockIndexer(t *testing.T) {
require.Equal(t, 1, len(wdPage.Withdrawals)) require.Equal(t, 1, len(wdPage.Withdrawals))
withdrawal := wdPage.Withdrawals[0] withdrawal := wdPage.Withdrawals[0]
require.Nil(t, withdrawal.BedrockProvenTxHash)
require.Nil(t, withdrawal.BedrockFinalizedTxHash) require.Nil(t, withdrawal.BedrockFinalizedTxHash)
require.Equal(t, big.NewInt(0.5*params.Ether).String(), withdrawal.Amount) require.Equal(t, big.NewInt(0.5*params.Ether).String(), withdrawal.Amount)
require.Equal(t, wdTx.Hash().String(), withdrawal.TxHash) require.Equal(t, wdTx.Hash().String(), withdrawal.TxHash)
...@@ -207,26 +208,48 @@ func TestBedrockIndexer(t *testing.T) { ...@@ -207,26 +208,48 @@ func TestBedrockIndexer(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
l1Opts.Value = big.NewInt(0) l1Opts.Value = big.NewInt(0)
withdrawalTx := bindings.TypesWithdrawalTransaction{
Nonce: wParams.Nonce,
Sender: wParams.Sender,
Target: wParams.Target,
Value: wParams.Value,
GasLimit: wParams.GasLimit,
Data: wParams.Data,
}
// Prove our withdrawal // Prove our withdrawal
proveTx, err := portal.ProveWithdrawalTransaction( proveTx, err := portal.ProveWithdrawalTransaction(
l1Opts, l1Opts,
bindings.TypesWithdrawalTransaction{ withdrawalTx,
Nonce: wParams.Nonce,
Sender: wParams.Sender,
Target: wParams.Target,
Value: wParams.Value,
GasLimit: wParams.GasLimit,
Data: wParams.Data,
},
wParams.L2OutputIndex, wParams.L2OutputIndex,
wParams.OutputRootProof, wParams.OutputRootProof,
wParams.WithdrawalProof, wParams.WithdrawalProof,
) )
require.NoError(t, err) require.NoError(t, err)
_, err = e2eutils.WaitReceiptOK(e2eutils.TimeoutCtx(t, time.Minute), l1Client, proveTx.Hash()) proveReceipt, err := e2eutils.WaitReceiptOK(e2eutils.TimeoutCtx(t, time.Minute), l1Client, proveTx.Hash())
require.NoError(t, err) require.NoError(t, err)
wdPage = nil
require.NoError(t, e2eutils.WaitFor(e2eutils.TimeoutCtx(t, 30*time.Second), 100*time.Millisecond, func() (bool, error) {
res := new(db.PaginatedWithdrawals)
err := getJSON(makeURL(fmt.Sprintf("v1/withdrawals/%s", fromAddr)), res)
if err != nil {
return false, err
}
if res.Withdrawals[0].BedrockProvenTxHash == nil {
return false, nil
}
wdPage = res
return true, nil
}))
wd := wdPage.Withdrawals[0]
require.Equal(t, proveReceipt.TxHash.String(), *wd.BedrockProvenTxHash)
require.Nil(t, wd.BedrockFinalizedTxHash)
// Wait for the finalization period to elapse // Wait for the finalization period to elapse
_, err = withdrawals.WaitForFinalizationPeriod( _, err = withdrawals.WaitForFinalizationPeriod(
e2eutils.TimeoutCtx(t, time.Minute), e2eutils.TimeoutCtx(t, time.Minute),
...@@ -239,14 +262,7 @@ func TestBedrockIndexer(t *testing.T) { ...@@ -239,14 +262,7 @@ func TestBedrockIndexer(t *testing.T) {
// Send our finalize withdrawal transaction // Send our finalize withdrawal transaction
finTx, err := portal.FinalizeWithdrawalTransaction( finTx, err := portal.FinalizeWithdrawalTransaction(
l1Opts, l1Opts,
bindings.TypesWithdrawalTransaction{ withdrawalTx,
Nonce: wParams.Nonce,
Sender: wParams.Sender,
Target: wParams.Target,
Value: wParams.Value,
GasLimit: wParams.GasLimit,
Data: wParams.Data,
},
) )
require.NoError(t, err) require.NoError(t, err)
...@@ -269,7 +285,8 @@ func TestBedrockIndexer(t *testing.T) { ...@@ -269,7 +285,8 @@ func TestBedrockIndexer(t *testing.T) {
return true, nil return true, nil
})) }))
wd := wdPage.Withdrawals[0] wd = wdPage.Withdrawals[0]
require.Equal(t, proveReceipt.TxHash.String(), *wd.BedrockProvenTxHash)
require.Equal(t, finReceipt.TxHash.String(), *wd.BedrockFinalizedTxHash) require.Equal(t, finReceipt.TxHash.String(), *wd.BedrockFinalizedTxHash)
require.True(t, *wd.BedrockFinalizedSuccess) require.True(t, *wd.BedrockFinalizedSuccess)
......
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