-
Notifications
You must be signed in to change notification settings - Fork 379
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
chore: attempt to improve OriginCall funcs #495
chore: attempt to improve OriginCall funcs #495
Conversation
`AssertOriginCall` and `IsOriginCall` relies on the number of frames to determine if the function was called by a gno transaction (definition taken from `examples/gno.land/r/demo/banktest/README.md`). Since this number is different in the context of test and filetest, the 2 functions are overrided during test setup, but the override works only for filetest files and not for test files. This change makes `AssertOriginCall` and `IsOriginCall` to rely on message's signers instead of frames. If the message has at east one signer, we consider the function was called by a gno tx. As a result, the functions no longer needs to be overrided in test setup, and they work both for filetest files and test files. Fix gnolang#481
Hey @tbruyelle, sorry for the delay; everything looks good, however, to make sure that it's stable and stays stable over time. It would be nice to add tests checking the consistency of this approach in the three main conditions:
We may add a unit test suite simulating the various Machine contexts so we can add more and more tests for |
Hey @moul no problem for the delay. You're right some tests are missing for a For About simulating a TX, could you give more details? Is it some kind of integration test ? |
f4d832e
to
405f13f
Compare
405f13f
to
dde938d
Compare
I added some tests for Indeed, the panic in this function occurred in go code, so it wasn't recoverable by gno code. Switching from |
After discussions with @moul, I realized my attempt to change My initial understanding on these functions was wrong. I though they were ensuring that the call comes from a transaction, but it's not only that, they also ensure that this call comes directly from a transaction, and not from an other contract. This is why they were relying on the number of frames to determine that origin call property. |
Please share your thoughts on PR #683. |
Closed in favor of #703 |
AssertOriginCall
andIsOriginCall
relies on the number of frames to determine if the function was called by a gno transaction (definition taken fromexamples/gno.land/r/demo/banktest/README.md
). Since this number is different in the context of test and filetest, the 2 functions are overrided during test setup, but the override works only for filetest files and not for test files.This change allows
AssertOriginCall
andIsOriginCall
to rely on message's signers instead of frames. If the message has at least one signer, we consider the function was called by a gno tx. As a result, the functions no longer needs to be overrided in test setup, and they work both for filetest files and test files.Fix #481