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

Transaction not identical after serialize/deserialize #1575

Closed
jbencin opened this issue Oct 19, 2023 · 0 comments · Fixed by #1630
Closed

Transaction not identical after serialize/deserialize #1575

jbencin opened this issue Oct 19, 2023 · 0 comments · Fixed by #1630
Assignees
Labels
bug Unwanted or unintended logic causing harm

Comments

@jbencin
Copy link
Member

jbencin commented Oct 19, 2023

What version of Stacks.js are you using?

4.3.8

Describe the bug

Serializing and the deserializing a transaction does not quite result in the same transaction. For example, this following vitest unit test will fail:

test('StacksTransaction serialize/deserialize', async () => {
  const options = { /* ... */ };
  const tx = await makeUnsignedSTXTokenTransfer(options);
  const tx_encoded = tx.serialize();
  const tx_decoded = deserializeTransaction(tx_encoded);

  expect(tx_decoded).toEqual(tx);
})

The reason it fails is that the memo.content field will have a large array of null bytes:

content: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

When it should be an empty string:

content: ''

How to reproduce

See example unit test above

Expected behavior

memo.content should deserialize to en empty string, and the deserialized StacksTransaction should deep equal the initial StacksTransaction

Additional context

This is using NodeJS 20.7.0

@jbencin jbencin added the bug Unwanted or unintended logic causing harm label Oct 19, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Oct 19, 2023
@janniks janniks self-assigned this Oct 23, 2023
@janniks janniks moved this from 🆕 New to 📋 Backlog in DevTools Oct 23, 2023
@janniks janniks moved this from 📋 Backlog to 🏗 In Progress in DevTools Jan 31, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in DevTools Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unwanted or unintended logic causing harm
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants