Skip to content

Commit

Permalink
fix/audit-15
Browse files Browse the repository at this point in the history
  • Loading branch information
whalelephant committed Dec 13, 2023
1 parent a36aa0f commit 4a7861f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/core
Submodule core updated from dc8104 to 20333a
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn deployer_can_add_subscription_tier() {
&app,
suite.deployer.clone(),
suite.plugin_registry.clone(),
&registry_management_trait::ExecMsg::AddSubscriptionTiers {
&registry_management_trait::ExecMsg::AddOrUpdateSubscriptionTiers {
tier: SubscriptionTier::Other as u8,
details: TierDetails {
max_plugins: 3,
Expand Down Expand Up @@ -65,7 +65,7 @@ fn existing_tier_cannot_be_added() {
&app,
suite.deployer.clone(),
suite.plugin_registry.clone(),
&registry_management_trait::ExecMsg::AddSubscriptionTiers {
&registry_management_trait::ExecMsg::AddOrUpdateSubscriptionTiers {
tier: current_tier,
details: TierDetails {
max_plugins: 3,
Expand All @@ -88,7 +88,7 @@ fn not_deployer_cannot_add_subscription_tier() {
// Sent from another signer
registry
.execute(
&registry_management_trait::ExecMsg::AddSubscriptionTiers {
&registry_management_trait::ExecMsg::AddOrUpdateSubscriptionTiers {
tier: SubscriptionTier::L1 as u8,
details: TierDetails {
max_plugins: 3,
Expand Down
33 changes: 33 additions & 0 deletions packages/vectis-tests/src/unit_tests/registry_mgmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,36 @@ fn new_plugin_version_with_same_code_id_fails() {

assert_eq!(err, PluginRegError::CodeIdAlreadyRegistered)
}

#[test]
fn can_update_subscription_tier() {
let suite = VectisTestSuite::new();
let registry = VectisPluginRegistryProxy::new(suite.plugin_registry, &suite.app);
let existing_tier = registry
.registry_management_trait_proxy()
.get_config()
.unwrap()
.subscription_tiers
.pop()
.unwrap();

let mut new_tier_details = existing_tier.1.clone();
new_tier_details.fee = coin(REGISTRY_FEE, DENOM);

registry
.registry_management_trait_proxy()
.add_or_update_subscription_tiers(existing_tier.0, new_tier_details)
.call(suite.deployer.as_str())
.unwrap();

let new_tier = registry
.registry_management_trait_proxy()
.get_config()
.unwrap()
.subscription_tiers
.pop()
.unwrap();

assert_eq!(existing_tier.0, new_tier.0);
assert_ne!(existing_tier.1, new_tier.1)
}
2 changes: 1 addition & 1 deletion packages/vectis/src/interface/plugin_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub mod registry_management_trait {
/// To remove tier there may already be subscribers and so it will require a migration
/// function
#[msg(exec)]
fn add_subscription_tiers(
fn add_or_update_subscription_tiers(
&self,
ctx: ExecCtx,
tier: u8,
Expand Down

0 comments on commit 4a7861f

Please sign in to comment.