Skip to content

xdr: Add marshal binary compress test #4076

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

Merged
merged 1 commit into from
Nov 17, 2021

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Nov 16, 2021

I wanted to make sure nothing broke on #4071 and there were no pre-existing tests.

For the record, I run the tests with the prior implementation and I could only see two justified differences:

  1. For LedgerEntryTypeOffer:
Expected :[]byte{0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}
Actual   :[]byte{0x2, 0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}          	

Which makes sense since we removed the SellerID from the output (which these 33 bytes []{0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3})

  1. For LedgerEntryTypeTrustline:
expected: []byte{0x1, 0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3, 0x1, 0x45, 0x55, 0x52, 0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3}
actual  : []byte{0x1, 0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3, 0x1, 0x45, 0x55, 0x52, 0x0, 0x0, 0x0, 0x0, 0x1d, 0x4, 0x9a, 0x80, 0xf, 0xda, 0x8f, 0xab, 0xe8, 0xf6, 0x9d, 0x10, 0xdd, 0x8d, 0xda, 0x79, 0x29, 0x5a, 0x14, 0x87, 0xca, 0xe2, 0x3e, 0x43, 0x4e, 0xf5, 0xab, 0x68, 0xec, 0x13, 0x6c, 0xf3}

There are three extra zeros {0x0, 0x0, 0x0}, which also makes sense because. For some reason, we weren't compressing assets issuers:

go/xdr/asset.go

Line 290 in d9d4986

issuer, err = a.AlphaNum4.Issuer.MarshalBinary()

(note that it isn't a binary compression call, but a normal binary call)

@2opremio 2opremio requested a review from a team November 16, 2021 14:31
@2opremio 2opremio force-pushed the binary-compress-test branch from e4db428 to 04dd40e Compare November 17, 2021 11:35
@2opremio 2opremio merged commit 5725e37 into stellar:master Nov 17, 2021
@2opremio 2opremio deleted the binary-compress-test branch November 17, 2021 12:08
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