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 tests for Celo2 Signer compatibility with both Celo1 and Celo2 transactions #308

Merged
merged 7 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions core/types/celo_transaction_signing_forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func (c *celoLegacy) txFuncs(tx *Transaction) *txFuncs {
return celoLegacyTxFuncs
case t == DynamicFeeTxType:
// We handle the dynamic fee tx type here because we need to handle
// migrated dynamic fee txs. These were enabeled in celo in the Espresso
// migrated dynamic fee txs. These were enabled in celo in the Espresso
// hardfork, which doesn't have any analogue in op-geth. Even though
// op-geth does enable support for dynamic fee txs in the London
// hardfork (which we set to the cel2 block) that fork contains a lot of
// changes that were not part of Espresso. So instead we ned to handle
// changes that were not part of Espresso. So instead we need to handle
// DynamicFeeTxTypes here.
return dynamicFeeTxFuncs
case t == AccessListTxType:
Expand Down
36 changes: 36 additions & 0 deletions core/types/celo_transaction_signing_forks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package types

import (
"testing"

"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/assert"
)

// Test_forks_activeForks tests that the correct forks are returned for a given block time and chain config
func Test_forks_activeForks(t *testing.T) {
t.Parallel()

cel2Time := uint64(1000)

t.Run("Non-Celo", func(t *testing.T) {
config := &params.ChainConfig{
Cel2Time: nil,
}
assert.Equal(t, []fork(nil), celoForks.activeForks(1000, config))
})

t.Run("Celo1", func(t *testing.T) {
config := &params.ChainConfig{
Cel2Time: &cel2Time,
}
assert.Equal(t, []fork{&celoLegacy{}}, celoForks.activeForks(500, config))
})

t.Run("Celo2", func(t *testing.T) {
config := &params.ChainConfig{
Cel2Time: &cel2Time,
}
assert.Equal(t, []fork{&cel2{}, &celoLegacy{}}, celoForks.activeForks(1000, config))
})
}
Loading
Loading