sbtc-developer-release icon indicating copy to clipboard operation
sbtc-developer-release copied to clipboard

test: Add `Codec` trait unit tests

Open ldiego08 opened this issue 1 year ago • 3 comments

Summary of Changes

  • Add unit tests to codec.rs to assert Codec implementations for the following works as expected:

    • bdk::bitcoin::Amount
    • bdk::bitcoin::Script
    • bdk::bitcoin::secp256k1::ecdsa::RecoverableSignature
    • u64
  • Add anyhow crate to stacks-core for easy error propagation in unit tests.

NOTE: There are some assertions against hex representations of the expected value to keep the tests as readable as possible and to avoid replicating the serialization or deserialization code. Formal snapshot testing using a crate like insta can prove a more scalable alternative asserting between complex values.

Testing

Run tests normally via cargo make test.

Risks

None.

How were these changes tested?

Changes are tests themselves and were verified by running cargo make test.

What future testing should occur?

None.

Checklist:

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

ldiego08 avatar Nov 17 '23 15:11 ldiego08

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 17 '23 15:11 CLAassistant

@CAGS295 seems like merging is blocked due to one workflow needing approval. Is there something else I need to do to get this merged?

ldiego08 avatar Nov 23 '23 15:11 ldiego08

Hi @ldiego08, thank you for your contribution. You need to wait for a core maintainer to approve the workflow. @AshtonStephens

CAGS295 avatar Nov 23 '23 16:11 CAGS295