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

Conversation

Kourin1996
Copy link

Closes #168

This PR introduces unit tests for celoSigner which was added in #165

The tests verify the following things:

  • celoSigner recover the sender's address from transactions created on Celo1 blockchain
  • celoSigner signs transactions for supported transaction types in Celo2
  • celoSigner correctly rejects signing unsupported transaction types in Celo2

celoSigner is designed to support transaction types compatible with Celo1 for history data support. Therefore, this PR includes signatures generated using celo-blockchain version v1.8.7. (Note: v1.8.4 produces identical results)

@Kourin1996 Kourin1996 self-assigned this Jan 13, 2025
@Kourin1996 Kourin1996 marked this pull request as ready for review January 13, 2025 07:07
@Kourin1996 Kourin1996 requested a review from piersy January 14, 2025 05:54

// Test_forks_findTxFuncs tests that the correct txFuncs are returned for a given transaction type and chain config
func Test_forks_findTxFuncs(t *testing.T) {
t.Parallel()
Copy link

@piersy piersy Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kourin1996 I think this test would be more useful if it tested from the level of the Signer using a similar approach to TestProtectedCeloLegacyTxSigning.

So generating a Signer for a given config and then signing each transaction with that signer and checking that the sender address can be correctly recovered, of course for some transactions an error will be returned because they are not supported or deprecated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piersy

I believe such cases are covered by TestCeloSigner_SignAndRecovery. TestCeloSigner_SignAndRecovery test focuses on signing only in Celo2 but includes actual scenarios.

On the other hand, this Test_forks_findTxFuncs test is just a low-level test designed to detect unexpected changes.

Copy link

@piersy piersy Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, what's being tested here is already covered by the two tests you mentioned. It seems to me that this test doesn’t add much value, so my preference would be to remove it. That said, I’m also fine with keeping it if you feel strongly about it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piersy OK. I removed it!

@Kourin1996 Kourin1996 requested a review from piersy January 22, 2025 04:30
@Kourin1996 Kourin1996 merged commit 461d643 into celo11 Jan 24, 2025
8 checks passed
@Kourin1996 Kourin1996 deleted the Kourin1996/add-legacy-tx-signing-tests branch January 24, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for legacy transaction signing
3 participants