Skip to content

Commit

Permalink
Added update_config test
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Baltariu <[email protected]>
  • Loading branch information
andreiblt1304 committed Dec 19, 2024
1 parent 245ce77 commit 382a7a7
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions chain-config/tests/chain_config_unit_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use multiversx_sc::types::{BigUint, TestAddress, TestSCAddress};
use multiversx_sc_scenario::{api::StaticApi, imports::MxscPath, ScenarioTxRun, ScenarioWorld};
use multiversx_sc_scenario::{
api::StaticApi, imports::MxscPath, ExpectError, ScenarioTxRun, ScenarioWorld,
};
use proxies::chain_config_proxy::ChainConfigContractProxy;
use transaction::SovereignConfig;

Expand Down Expand Up @@ -41,15 +43,24 @@ impl ChainConfigTestState {
.run();
}

fn update_chain_config(&mut self, config: SovereignConfig<StaticApi>) {
self.world
fn update_chain_config(
&mut self,
config: SovereignConfig<StaticApi>,
expect_error: Option<ExpectError>,
) {
let transaction = self
.world
.tx()
.from(OWNER)
.to(CONFIG_ADDRESS)
.typed(ChainConfigContractProxy)
.update_config(config)
.code(CONFIG_CODE_PATH)
.new_address(CONFIG_ADDRESS)
.run();
.update_config(config);

if let Some(error) = expect_error {
transaction.returns(error).run();
} else {
transaction.run();
}
}
}

Expand All @@ -60,3 +71,15 @@ fn deploy_chain_config() {
let config = SovereignConfig::new(0, 1, BigUint::default(), None);
state.deploy_chain_config(config, OWNER);
}

#[test]
fn update_config() {
let mut state = ChainConfigTestState::new();

let config = SovereignConfig::new(0, 1, BigUint::default(), None);
state.deploy_chain_config(config, OWNER);

let new_config = SovereignConfig::new(2, 4, BigUint::default(), None);

state.update_chain_config(new_config, None);
}

0 comments on commit 382a7a7

Please sign in to comment.