From a5439ec8b996d9ed96f5a56d1be121f43b772959 Mon Sep 17 00:00:00 2001 From: axelKingsley Date: Wed, 6 Nov 2024 16:04:45 -0600 Subject: [PATCH] fix test --- op-e2e/interop/interop_test.go | 36 +++++++++++++++++++--------------- op-e2e/interop/supersystem.go | 13 +++++++++++- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/op-e2e/interop/interop_test.go b/op-e2e/interop/interop_test.go index fb902effec50..6ab727909623 100644 --- a/op-e2e/interop/interop_test.go +++ b/op-e2e/interop/interop_test.go @@ -278,13 +278,14 @@ func TestInteropBlockBuilding(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*15) defer cancel() // Send an executing message, but with different payload. - // We expect the miner to be unable to include this tx, and confirmation to thus time out. - _, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, invalidPayload) - require.NotNil(t, err) - require.ErrorIs(t, err, ctx.Err()) if s2.(*interopE2ESystem).config.mempoolFiltering { - require.ErrorIs(t, ctx.Err(), gethCore.ErrTxFilteredOut) + // We expect the traqnsaction to be filtered out by the mempool if mempool filtering is enabled. + // nothing is returned, but in ExecuteMessage the ErrTxFilteredOut error is checked when sending the tx. + s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, invalidPayload, gethCore.ErrTxFilteredOut) } else { + // We expect the miner to be unable to include this tx, and confirmation to thus time out, if mempool filtering is disabled. + _, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, invalidPayload, nil) + require.ErrorIs(t, err, ctx.Err()) require.ErrorIs(t, ctx.Err(), context.DeadlineExceeded) } } @@ -295,22 +296,25 @@ func TestInteropBlockBuilding(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*15) defer cancel() // Send an executing message with the correct identifier / payload - rec, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, msgPayload) + rec, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, msgPayload, nil) require.NoError(t, err, "expecting tx to be confirmed") t.Logf("confirmed executing msg in block %s", rec.BlockNumber) } t.Log("Done") } - config := SuperSystemConfig{ - mempoolFiltering: false, - } - // run once without mempool filtering to observe the miner behavior - setupAndRun(t, config, test) + t.Run("without mempool filtering", func(t *testing.T) { + config := SuperSystemConfig{ + mempoolFiltering: false, + } + setupAndRun(t, config, test) + }) - config = SuperSystemConfig{ - mempoolFiltering: true, - } - // run again with mempool filtering to observe the behavior of the mempool filter - setupAndRun(t, config, test) + t.Run("with mempool filtering", func(t *testing.T) { + config := SuperSystemConfig{ + mempoolFiltering: true, + } + // run again with mempool filtering to observe the behavior of the mempool filter + setupAndRun(t, config, test) + }) } diff --git a/op-e2e/interop/supersystem.go b/op-e2e/interop/supersystem.go index 73aab20b5dd7..448e78964669 100644 --- a/op-e2e/interop/supersystem.go +++ b/op-e2e/interop/supersystem.go @@ -114,6 +114,7 @@ type SuperSystem interface { msgIdentifier supervisortypes.Identifier, target common.Address, message []byte, + expectedError error, ) (*types.Receipt, error) // Access a contract on a network by name Contract(network string, contractName string) interface{} @@ -726,6 +727,10 @@ func (s *interopE2ESystem) SendL2Tx( newApply) } +// ExecuteMessage calls the CrossL2Inbox executeMessage function +// it uses the L2's chain ID, username key, and geth client. +// expectedError represents the error returned by `ExecuteMessage` if it is expected. +// the returned err is related to `WaitMined` func (s *interopE2ESystem) ExecuteMessage( ctx context.Context, id string, @@ -733,6 +738,7 @@ func (s *interopE2ESystem) ExecuteMessage( msgIdentifier supervisortypes.Identifier, target common.Address, message []byte, + expectedError error, ) (*types.Receipt, error) { secret := s.UserKey(id, sender) auth, err := bind.NewKeyedTransactorWithChainID(&secret, s.l2s[id].chainID) @@ -751,7 +757,12 @@ func (s *interopE2ESystem) ExecuteMessage( ChainId: msgIdentifier.ChainID.ToBig(), } tx, err := contract.InboxTransactor.ExecuteMessage(auth, identifier, target, message) - require.NoError(s.t, err) + if expectedError != nil { + require.ErrorContains(s.t, err, expectedError.Error()) + return nil, nil + } else { + require.NoError(s.t, err) + } s.logger.Info("Executing message", "tx", tx.Hash(), "to", tx.To(), "target", target, "data", hexutil.Bytes(tx.Data())) return bind.WaitMined(ctx, s.L2GethClient(id), tx) }