Skip to content

Commit

Permalink
fixed test case and use source hash as identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
s4rv4d committed Dec 12, 2024
1 parent f74c4f6 commit 11ab649
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions opsimulator/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 8 additions & 3 deletions supersim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 11ab649

Please sign in to comment.