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

[action]: add unit test for eth tx decode verify #4291

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

saitofun
Copy link
Contributor

@saitofun saitofun commented Jun 5, 2024

Description

add unit test TestEthTxDecodeVerifyV2, building eth tx raw data and assertions instead of using hex raw data directly.
add unit test TestEthTxUtils to verify some eth wrapped functions.

Fixes #(issue)

Type of change

  • Code refactor or improvement

How Has This Been Tested?

  • [] make test

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

sender2, _ := signer2.Sender(tx2)
r.Equal(sender1, sender2)

// r.Equal(sender1.Bytes(), pk1.Address().Bytes())
Copy link
Member

Choose a reason for hiding this comment

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

delete unused code?

pk1recover, _ := iotexcrypto.RecoverPubkey(signer1.Hash(tx).Bytes(), sig1)
t.Log(hex.EncodeToString(pk1recover.Bytes()))
pk2recoverbytes, _ := ethercrypto.Ecrecover(signer2.Hash(tx).Bytes(), sig2)
t.Log(hex.EncodeToString(pk2recoverbytes))
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete t.Log

Copy link

sonarcloud bot commented Jun 7, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@saitofun saitofun merged commit 9a71344 into master Jun 7, 2024
3 checks passed
@saitofun saitofun deleted the test_eth_tx_decode_verify branch June 7, 2024 01:03
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.

3 participants