From 11ab6499ccc3e2d4d9113a974d16bf0af26a1b37 Mon Sep 17 00:00:00 2001 From: serverConnected Date: Thu, 12 Dec 2024 15:30:05 +0530 Subject: [PATCH] fixed test case and use source hash as identifier --- opsimulator/indexer.go | 5 ++--- supersim_test.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/opsimulator/indexer.go b/opsimulator/indexer.go index 9f4ad477..bc980f3e 100644 --- a/opsimulator/indexer.go +++ b/opsimulator/indexer.go @@ -102,10 +102,9 @@ func (i *L1ToL2MessageIndexer) createSubscription(key string, depositMessageChan func (i *L1ToL2MessageIndexer) processEvent(dep *types.DepositTx, chainID uint64) error { depTx := types.NewTx(dep) - i.log.Info("observed deposit event on L1", "hash", depTx.Hash().String()) - fmt.Println(depTx.Hash().String()) + i.log.Info("observed deposit event on L1", "hash", depTx.Hash().String(), "SourceHash", dep.SourceHash.String()) - if err := i.storeManager.Set(depTx.Hash(), dep); err != nil { + if err := i.storeManager.Set(dep.SourceHash, dep); err != nil { i.log.Error("failed to store deposit tx to chain: %w", "chain.id", chainID, "err", err) return err } diff --git a/supersim_test.go b/supersim_test.go index 237cc80b..4f696526 100644 --- a/supersim_test.go +++ b/supersim_test.go @@ -10,7 +10,9 @@ import ( "github.com/ethereum-optimism/optimism/op-chain-ops/devkeys" opbindings "github.com/ethereum-optimism/optimism/op-e2e/bindings" + "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/receipts" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-service/predeploys" "github.com/ethereum-optimism/optimism/op-service/testlog" registry "github.com/ethereum-optimism/superchain-registry/superchain" @@ -1169,10 +1171,13 @@ func TestAdminGetL1ToL2MessageByTxnHash(t *testing.T) { // check that balance was increased require.Equal(t, oneEth, postBalance.Sub(postBalance, prevBalance), "Recipient balance is incorrect") + depositEvent, err := receipts.FindLog(txReceipt.Logs, optimismPortal.ParseTransactionDeposited) + require.NoError(t, err, "Should emit deposit event") + depositTx, err := derive.UnmarshalDepositLogEvent(&depositEvent.Raw) + require.NoError(t, err) + var message *admin.JSONDepositTx - // msgHash for the above sendERC20 txn - l1TxnHash := txReceipt.TxHash - rpcErr := adminRPCClient.CallContext(context.Background(), &message, "admin_getL1ToL2MessageByTxnHash", l1TxnHash) + rpcErr := adminRPCClient.CallContext(context.Background(), &message, "admin_getL1ToL2MessageByTxnHash", depositTx.SourceHash) require.NoError(t, rpcErr) assert.Equal(t, oneEth.String(), message.Value.String())