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

fix(wasm-dpp): serialization bugs and failing tests #1030

Merged
merged 8 commits into from
May 5, 2023
Merged

Conversation

markin-io
Copy link
Contributor

@markin-io markin-io commented May 4, 2023

Issue being fixed or feature implemented

Fixed wasm logic and tests to reflect latest rs-dpp updates

What was done?

  • Refactored toBuffer methods to use PlatformSerializable
  • Refactored fromBuffer methods of factories to use PlatformSerializable
  • Disabled decodeProtocolEntity tests and commented code
  • Fixed JS tests

How Has This Been Tested?

  • CI

Breaking Changes

toBuffer now returns bincode instead of cbor

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@markin-io markin-io changed the title fix(wasm-dpp): fixed tests fix(wasm-dpp): serialization bugs and failing tests May 4, 2023
@@ -68,6 +74,47 @@ pub struct ExtendedDocument {
pub entropy: Bytes32,
}

impl Encode for ExtendedDocument {
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how it works - is the data being written to the encoder directly and then something like encoder.finalize() is called?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well yes, when you derive Encode it takes every attribute and encodes them and puts them back to back, but you don't need to derive, you can do things manually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm more interested in how the API works. For example, if you want to serialize something to a vec, you write something like let encoded: Vec<u8> = bincode::serialize(&doc).unwrap();, and then bincode figures out the encoder internally? I'm not really familiar with the barcode just yet, so I was wondering if my assumption is right

Copy link
Collaborator

@antouhou antouhou May 5, 2023

Choose a reason for hiding this comment

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

This is not exactly a comment to this specific code, just figured that this is the place I can ask about it as well :)

@antouhou antouhou merged commit acaad44 into v0.25-dev May 5, 2023
@antouhou antouhou deleted the fix/wasm-dpp branch May 5, 2023 11:58
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.

None yet

3 participants