-
Notifications
You must be signed in to change notification settings - Fork 9
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
Sylvia upgrade #188
Merged
Merged
Sylvia upgrade #188
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9f81b06
Upgrade Sylvia to 0.10, fix as many things as possible
94171cc
Attempt to fix up virtual staking, still doesn't compile
71dffdf
Got consumer/converter to compile (but not tests)
ethanfrey 437fcc4
Remove codecov as we only get errors (seems it needs a paid API key?)
ethanfrey 528c6e1
Use `sylvia::types::Proxy` in consumer converter tests
jawoznia a34baf2
Clippy also happy for converter contract
ethanfrey 12605d3
Virtual-staking compiles
ethanfrey 1d3772e
Lost in a message of custom msg/query types
ethanfrey 632ee1b
External and native staking compile, some tests fail
ethanfrey 9b2be17
Everything runs minus virtual-staking, some tests fail
ethanfrey 180aa1e
Clean up obvious errors in virtual-staking
ethanfrey 3fa51d7
More virtual staking cleanup
ethanfrey 19b17c2
Restore original jailing logic
ethanfrey c4c34f6
Native-staking* and vault tests pass
ethanfrey 3db923e
Workaround to enable communication between `Empty` and `Custom`
jawoznia 07fb1ca
More generic, simple-price and converter pass tests
ethanfrey 1009590
virtual-staking tests work
ethanfrey 4938265
Test pass, clippy happy :)
ethanfrey 3092f95
Wasm compilation proper again
ethanfrey c5bbcc4
More clippy fixes
ethanfrey 19e50b2
Merge pull request #189 from osmosis-labs/sylvia-upgrade-custom-empty
ethanfrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,20 @@ mod virtual_staking_mock; | |
|
||
use cosmwasm_std::{coin, coins, Addr, Decimal, StdError, Uint128, Validator}; | ||
use cw_multi_test::App as MtApp; | ||
use mesh_apis::converter_api::sv::mt::ConverterApiProxy; | ||
use mesh_apis::converter_api::RewardInfo; | ||
use sylvia::multitest::App; | ||
|
||
use crate::contract; | ||
use crate::contract::test_utils::ConverterApi; | ||
use mesh_simple_price_feed::contract::sv::mt::CodeId as PriceFeedCodeId; | ||
use mesh_simple_price_feed::contract::SimplePriceFeedContract; | ||
use sylvia::multitest::{App, Proxy}; | ||
use virtual_staking_mock::sv::mt::CodeId as VirtualStakingCodeId; | ||
use virtual_staking_mock::VirtualStakingMock; | ||
|
||
use crate::contract::sv::mt::CodeId as ConverterCodeId; | ||
use crate::contract::sv::mt::ConverterContractProxy; | ||
use crate::contract::ConverterContract; | ||
use crate::error::ContractError; | ||
use crate::error::ContractError::Unauthorized; | ||
use crate::multitest::virtual_staking_mock::sv::mt::VirtualStakingMockProxy; | ||
|
||
const JUNO: &str = "ujuno"; | ||
|
||
|
@@ -20,10 +27,9 @@ struct SetupArgs<'a> { | |
} | ||
|
||
struct SetupResponse<'a> { | ||
price_feed: | ||
mesh_simple_price_feed::contract::multitest_utils::SimplePriceFeedContractProxy<'a, MtApp>, | ||
converter: contract::multitest_utils::ConverterContractProxy<'a, MtApp>, | ||
virtual_staking: virtual_staking_mock::multitest_utils::VirtualStakingMockProxy<'a, MtApp>, | ||
price_feed: Proxy<'a, MtApp, SimplePriceFeedContract<'a>>, | ||
converter: Proxy<'a, MtApp, ConverterContract<'a>>, | ||
virtual_staking: Proxy<'a, MtApp, VirtualStakingMock<'a>>, | ||
} | ||
|
||
fn setup<'a>(app: &'a App<MtApp>, args: SetupArgs<'a>) -> SetupResponse<'a> { | ||
|
@@ -34,10 +40,9 @@ fn setup<'a>(app: &'a App<MtApp>, args: SetupArgs<'a>) -> SetupResponse<'a> { | |
native_per_foreign, | ||
} = args; | ||
|
||
let price_feed_code = | ||
mesh_simple_price_feed::contract::multitest_utils::CodeId::store_code(app); | ||
let virtual_staking_code = virtual_staking_mock::multitest_utils::CodeId::store_code(app); | ||
let converter_code = contract::multitest_utils::CodeId::store_code(app); | ||
let price_feed_code = PriceFeedCodeId::store_code(app); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage actually looks simpler |
||
let virtual_staking_code = VirtualStakingCodeId::store_code(app); | ||
let converter_code = ConverterCodeId::store_code(app); | ||
|
||
let price_feed = price_feed_code | ||
.instantiate(native_per_foreign, None) | ||
|
@@ -60,10 +65,11 @@ fn setup<'a>(app: &'a App<MtApp>, args: SetupArgs<'a>) -> SetupResponse<'a> { | |
|
||
let config = converter.config().unwrap(); | ||
let virtual_staking_addr = Addr::unchecked(config.virtual_staking); | ||
let virtual_staking = virtual_staking_mock::multitest_utils::VirtualStakingMockProxy::new( | ||
virtual_staking_addr, | ||
app, | ||
); | ||
// Ideally this should be initialized via `CodeId`. | ||
// Consider bellow approach | ||
// | ||
// let virtual_staking = virtual_staking_code.instantiate().call(owner).unwrap(); | ||
let virtual_staking = Proxy::new(virtual_staking_addr, app); | ||
|
||
SetupResponse { | ||
price_feed, | ||
|
@@ -328,13 +334,11 @@ fn valset_update_works() { | |
|
||
// Check that only the virtual staking contract can call this handler | ||
let res = converter | ||
.converter_api_proxy() | ||
.valset_update(vec![], vec![], vec![], vec![], vec![], vec![], vec![]) | ||
.call(owner); | ||
assert_eq!(res.unwrap_err(), Unauthorized {}); | ||
|
||
let res = converter | ||
.converter_api_proxy() | ||
.valset_update( | ||
add_validators, | ||
rem_validators, | ||
|
@@ -374,7 +378,6 @@ fn unauthorized() { | |
); | ||
|
||
let err = converter | ||
.converter_api_proxy() | ||
.distribute_rewards(vec![ | ||
RewardInfo { | ||
validator: "alice".to_string(), | ||
|
@@ -391,15 +394,13 @@ fn unauthorized() { | |
assert_eq!(err, ContractError::Unauthorized); | ||
|
||
let err = converter | ||
.converter_api_proxy() | ||
.distribute_reward("validator".to_string()) | ||
.call("mallory") | ||
.unwrap_err(); | ||
|
||
assert_eq!(err, ContractError::Unauthorized); | ||
|
||
let err = converter | ||
.converter_api_proxy() | ||
.valset_update(vec![], vec![], vec![], vec![], vec![], vec![], vec![]) | ||
.call("mallory") | ||
.unwrap_err(); | ||
|
@@ -442,7 +443,6 @@ fn distribute_rewards_invalid_amount_is_rejected() { | |
}); | ||
|
||
let err = converter | ||
.converter_api_proxy() | ||
.distribute_rewards(vec![ | ||
RewardInfo { | ||
validator: "alice".to_string(), | ||
|
@@ -466,7 +466,6 @@ fn distribute_rewards_invalid_amount_is_rejected() { | |
); | ||
|
||
let err = converter | ||
.converter_api_proxy() | ||
.distribute_rewards(vec![ | ||
RewardInfo { | ||
validator: "alice".to_string(), | ||
|
@@ -526,7 +525,6 @@ fn distribute_rewards_valid_amount() { | |
}); | ||
|
||
converter | ||
.converter_api_proxy() | ||
.distribute_rewards(vec![ | ||
RewardInfo { | ||
validator: "alice".to_string(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Okay, this is a lot of non-intuitive changes, but happy to use this as an example to fix others.
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 change is because we moved out of generating
Proxy
type percontract
macro.Instead we have a
sylvia::multitest::Proxy
type that is generic overMtApp
on which theSimplePriceFeedContract
is deployed. So the idea was to link via proxy some contract to the chain.