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 test for ArbitrumDepositTxType transaction types #1725

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions system_tests/retryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ func retryableSetup(t *testing.T) (
}
var submissionTxs []*types.Transaction
for _, message := range messages {
if message.Message.Header.Kind != arbostypes.L1MessageType_SubmitRetryable {
k := message.Message.Header.Kind
if k != arbostypes.L1MessageType_SubmitRetryable && k != arbostypes.L1MessageType_EthDeposit {
continue
}
txs, err := arbos.ParseL2Transactions(message.Message, params.ArbitrumDevTestChainConfig().ChainID, nil)
Require(t, err)
for _, tx := range txs {
if tx.Type() == types.ArbitrumSubmitRetryableTxType {
if tx.Type() == types.ArbitrumSubmitRetryableTxType || tx.Type() == types.ArbitrumDepositTxType {
submissionTxs = append(submissionTxs, tx)
}
}
Expand Down Expand Up @@ -395,3 +396,49 @@ func waitForL1DelayBlocks(t *testing.T, ctx context.Context, l1client *ethclient
})
}
}

func TestDepositETH(t *testing.T) {
t.Parallel()
_, l1info, l2client, l1client, delayedInbox, lookupSubmitRetryableL2TxHash, ctx, teardown := retryableSetup(t)
defer teardown()

faucetAddr := l1info.GetAddress("Faucet")

oldBalance, err := l2client.BalanceAt(ctx, faucetAddr, nil)
if err != nil {
t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err)
}

txOpts := l1info.GetDefaultTransactOpts("Faucet", ctx)
txOpts.Value = big.NewInt(13)

l1tx, err := delayedInbox.DepositEth0(&txOpts)
if err != nil {
t.Fatalf("DepositEth0() unexected error: %v", err)
}

l1Receipt, err := EnsureTxSucceeded(ctx, l1client, l1tx)
if err != nil {
t.Fatalf("EnsureTxSucceeded() unexpected error: %v", err)
}
if l1Receipt.Status != types.ReceiptStatusSuccessful {
t.Errorf("Got transaction status: %v, want: %v", l1Receipt.Status, types.ReceiptStatusSuccessful)
}
waitForL1DelayBlocks(t, ctx, l1client, l1info)

txHash := lookupSubmitRetryableL2TxHash(l1Receipt)
l2Receipt, err := WaitForTx(ctx, l2client, txHash, time.Second*5)
if err != nil {
t.Fatalf("WaitForTx(%v) unexpected error: %v", txHash, err)
}
if l2Receipt.Status != types.ReceiptStatusSuccessful {
t.Errorf("Got transaction status: %v, want: %v", l2Receipt.Status, types.ReceiptStatusSuccessful)
}
newBalance, err := l2client.BalanceAt(ctx, faucetAddr, l2Receipt.BlockNumber)
if err != nil {
t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err)
}
if got := new(big.Int); got.Sub(newBalance, oldBalance).Cmp(txOpts.Value) != 0 {
t.Errorf("Got transferred: %v, want: %v", got, txOpts.Value)
}
}