-
Notifications
You must be signed in to change notification settings - Fork 85
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
add function to get blockchain id from warp precompile #2633
Conversation
pkg/precompiles/warp.go
Outdated
if err != nil { | ||
return ids.Empty, err | ||
} | ||
received, b := out[0].([32]byte) |
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.
Do we need to validate the out array here before we check the 0 index? Also, is the type conversion safe to call or do we need to catch any potential errors from it?
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.
For the second question, I could be rusty on Go. More so, I am looking to confirm that this conversion fails, if it'll throw an uncaught error
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.
First question. We are counting that the underlying implementation, if does not error, returns out
with the appropriate size. This is the current semantic.
That say, better to check for len!
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.
Second question. The type conversion is safe if you also get the b boolean. I mean, there is no uncaught error.
If you do
received := out[0].([32]byte)
you can have uncaught error.
If you do
received, b := out[0].([32]byte)
you will have b==false in conversion error
pkg/precompiles/warp.go
Outdated
return ids.Empty, err | ||
} | ||
received, b := out[0].([32]byte) | ||
if !b { |
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.
What is the variable b?
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.
if the value exists, should prob rename it to ok @felipemadero
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.
ok
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.
b == type conversion ok
"github.com/ava-labs/avalanchego/ids" | ||
) | ||
|
||
func WarpPrecompileGetBlockchainID( |
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.
Do we have any sort of framework/etc in place for testing functions like these (ie one's that would require a lot of mocking)?
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 can test this on local network. Do u want to create separate PR for this? @felipemadero
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 don't have framework in place for testing this as unit test. we usually do E2E testing with a local network
deployment, not with a mock. for sure we can consider mocking if we want to really add testing for
all code paths.
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.
really, how to unit test this stuff, and how to properly tests the commands ux, for example
(prompts, flags paths), needs good design
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.
open to freely talk on implementation options
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.
regarding testing this specific feature on E2E, we don't have a command to return blockchain ID,
but it is going to be part of a larger feature in the short term.
#2637
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.
do we want to add annotations to the functions to point to the specific E2E?
001d27a
to
8947a39
Compare
Why this should be merged
To avoid the user to input information we cat retrieve from the validators
How this works
How this was tested
How is this documented