Skip to content

Commit

Permalink
Fix in mem tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed May 14, 2024
1 parent afb01a1 commit 61cd4ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 31 deletions.
31 changes: 0 additions & 31 deletions go/enclave/crosschain/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,6 @@ func receiptsHash(receipts types.Receipts) string {
return hash.Hex()
}

/*
func lazilyLogChecksum(msg string, transactions types.Transactions, logger gethlog.Logger) {
logger.Trace(msg, "Hash",
gethlog.Lazy{Fn: func() string {
hasher := sha3.NewLegacyKeccak256().(crypto.KeccakState)
hasher.Reset()
for _, tx := range transactions {
var buffer bytes.Buffer
err := tx.EncodeRLP(&buffer)
if err != nil {
return err.Error()
}
hasher.Write(buffer.Bytes())
}
var hash gethcommon.Hash
_, err := hasher.Read(hash[:])
if err != nil {
return err.Error()
}
return hash.Hex()
}})
}
*/

// filterLogsFromReceipts - filters the receipts for logs matching address, if provided and topic if provided.
func filterLogsFromReceipts(receipts types.Receipts, address *gethcommon.Address, topics []*gethcommon.Hash) ([]types.Log, error) {
logs := make([]types.Log, 0)
Expand Down Expand Up @@ -234,12 +209,6 @@ func (ms MessageStructs) ForMerkleTree() [][]interface{} {

func (ms MessageStructs) HashPacked(index int) gethcommon.Hash {
messageStruct := ms[index]
/* Sender common.Address
Sequence uint64
Nonce uint32
Topic uint32
Payload []byte
ConsistencyLevel uint8 */

addrType, _ := abi.NewType("address", "", nil)
uint64Type, _ := abi.NewType("uint64", "", nil)
Expand Down
5 changes: 5 additions & 0 deletions go/ethadapter/mgmtcontractlib/mgmt_contract_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const methodBytesLen = 4
// MgmtContractLib provides methods for creating ethereum transactions by providing an L1Transaction, creating call
// messages for call requests, and converting ethereum transactions into L1Transactions.
type MgmtContractLib interface {
IsMock() bool
CreateRollup(t *ethadapter.L1RollupTx) types.TxData
CreateRequestSecret(tx *ethadapter.L1RequestSecretTx) types.TxData
CreateRespondSecret(tx *ethadapter.L1RespondSecretTx, verifyAttester bool) types.TxData
Expand Down Expand Up @@ -66,6 +67,10 @@ func NewMgmtContractLib(addr *gethcommon.Address, logger gethlog.Logger) MgmtCon
}
}

func (c *contractLibImpl) IsMock() bool {
return false
}

func (c *contractLibImpl) GetContractAddr() *gethcommon.Address {
return c.addr
}
Expand Down
4 changes: 4 additions & 0 deletions go/host/l1/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ func (p *Publisher) PublishRollup(producedRollup *common.ExtRollup) {
}

func (p *Publisher) PublishCrossChainBundle(bundle *common.ExtCrossChainBundle) {
if p.mgmtContractLib.IsMock() {
return
}

if len(bundle.CrossChainHashes) == 0 {
return
}
Expand Down
4 changes: 4 additions & 0 deletions integration/ethereummock/mgmt_contract_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func NewMgmtContractLibMock() mgmtcontractlib.MgmtContractLib {
return &mockContractLib{}
}

func (m *mockContractLib) IsMock() bool {
return true
}

func (m *mockContractLib) GetContractAddr() *gethcommon.Address {
return &rollupTxAddr
}
Expand Down

0 comments on commit 61cd4ad

Please sign in to comment.