-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(upgrader): add generalized atomic upgrade and migration capabilities #77
Conversation
# Conflicts: # contracts/axelar-gateway/src/contract.rs # contracts/axelar-gateway/src/error.rs
# Conflicts: # contracts/axelar-gateway/src/contract.rs
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
=======================================
Coverage ? 93.58%
=======================================
Files ? 34
Lines ? 1824
Branches ? 0
=======================================
Hits ? 1707
Misses ? 117
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
contracts/upgrader/src/contract.rs
Outdated
let contract_address = env.register(DummyContract, ()); | ||
let upgrader_address = env.register(Upgrader, ()); | ||
|
||
let _owner = set_owner(&env, &contract_address); |
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.
create a setup_env helper that sets up the env and contract clients, similar to other tests
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 need the owner, and contract addresses throughout the code. I find
let owner = Address::generate(&env);
let contract_address = env.register(DummyContract, (&owner,));
let upgrader_address = env.register(Upgrader, ());
cleaner than
let (owner, contract_address, upgrader_address) = setup(&env)
...
fn setup(env: &Env){
let owner = Address::generate(env);
let contract_address = env.register(DummyContract, (&owner,));
let upgrader_address = env.register(Upgrader, ());
}
}, | ||
MockAuth { | ||
address: &owner, | ||
invoke: &migrate_auth, |
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.
Try using assert_invoke_auth_err
instead? You can add another pattern for it where it takes a list of callers and invocation calls and creates mock auths for them, and then calls the final method to test the 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.
the auth that I need to mock here is very specific for this scenario: I call function A, but need to authenticate functions B and C that have very specific subsets of the input parameters. Also, the tests are modulating what is authenticated and what is not, so there is no good macro solution, and it wouldn't be reusable anyway
AXE-6099