-
Notifications
You must be signed in to change notification settings - Fork 187
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
Expose abi encoding #266
Expose abi encoding #266
Conversation
Struct, | ||
}; | ||
use yultsur::*; | ||
|
||
#[test] | ||
fn test_new() { | ||
let mut val = Struct::new("Foo"); | ||
val.add_field("bar", &Base::Bool); | ||
val.add_field("bar2", &Base::Bool); | ||
val.add_field("bar", &FixedSize::Base(Base::Bool)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could add functions like FixedSize::bool()
to make tests cleaner
Codecov Report
@@ Coverage Diff @@
## master #266 +/- ##
==========================================
- Coverage 93.94% 93.73% -0.21%
==========================================
Files 54 54
Lines 3798 3816 +18
==========================================
+ Hits 3568 3577 +9
- Misses 230 239 +9
Continue to review full report at Codecov.
|
c07d8e9
to
d67da4a
Compare
d67da4a
to
c1b5404
Compare
// less than 32 bytes. So, when we get the pointer to the value of a struct | ||
// field, we must take into consideration the left-padding. The left-padding is | ||
// equal to the difference between the value's size and 32 bytes, so we end up | ||
// adding the word offset and the byte offset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
0, 0, 0, 0, 1, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how the nitty gritty details exposed by this test!
@@ -303,3 +309,58 @@ fn test_runtime_set_zero() { | |||
); | |||
}) | |||
} | |||
|
|||
#[test] | |||
fn test_runtime_house_struct() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is such a cool test 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super cool PR! Looks great 👍
What was wrong?
The main goal of this PR is to implement ABI encoding for structs and expose it the user via a builtin attribute function
abi_encode()
.How was it fixed?
AbiEncoding
trait for structs. This was quite easy since structs are already encoded following the ABI standard.abi_encode()
attribute function for structs.There were a few other things that I ran into and fixed/changed.
field_index * 32 + (32 - field_size)
instead offield_index * 32
, which fixed a bug I was seeing.dimension
tosize
. This should be correct terminology.To-Do
Update Spec if applicable
Add entry to the release notes (may forgo for trivial changes)
Clean up commit history