Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add retryable expiry system tests #2799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

magicxyyz
Copy link
Contributor

@magicxyyz magicxyyz commented Nov 19, 2024

Resolves NIT-2874

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Nov 19, 2024
Comment on lines +475 to +522
builder, delayedInbox, lookupL2Tx, ctx, teardown := retryableSetup(t)
defer teardown()

ownerTxOpts := builder.L2Info.GetDefaultTransactOpts("Owner", ctx)
usertxopts := builder.L1Info.GetDefaultTransactOpts("Faucet", ctx)
usertxopts.Value = arbmath.BigMul(big.NewInt(1e12), big.NewInt(1e12))

simpleAddr, _ := builder.L2.DeploySimple(t, ownerTxOpts)
simpleABI, err := mocksgen.SimpleMetaData.GetAbi()
Require(t, err)

beneficiaryAddress := builder.L2Info.GetAddress("Beneficiary")
l1tx, err := delayedInbox.CreateRetryableTicket(
&usertxopts,
simpleAddr,
common.Big0,
big.NewInt(1e16),
beneficiaryAddress,
beneficiaryAddress,
// send enough L2 gas for intrinsic but not compute
big.NewInt(int64(params.TxGas+params.TxDataNonZeroGasEIP2028*4)),
big.NewInt(l2pricing.InitialBaseFeeWei*2),
simpleABI.Methods["incrementRedeem"].ID,
)
Require(t, err)

l1Receipt, err := builder.L1.EnsureTxSucceeded(l1tx)
Require(t, err)
if l1Receipt.Status != types.ReceiptStatusSuccessful {
Fatal(t, "l1Receipt indicated failure")
}

waitForL1DelayBlocks(t, builder)

receipt, err := builder.L2.EnsureTxSucceeded(lookupL2Tx(l1Receipt))
Require(t, err)
if len(receipt.Logs) != 2 {
Fatal(t, len(receipt.Logs))
}
ticketId := receipt.Logs[0].Topics[1]
firstRetryTxId := receipt.Logs[1].Topics[2]

// make sure it failed
receipt, err = WaitForTx(ctx, builder.L2.Client, firstRetryTxId, time.Second*5)
Require(t, err)
if receipt.Status != types.ReceiptStatusFailed {
Fatal(t, receipt.GasUsed)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior is being implemented several times already in this file, how about having another setup function to abstract that and avoid code repetition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants