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 20, 2024
1 parent de2c412 commit 0fe84cf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions chain-config/tests/chain_config_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use transaction::SovereignConfig;
const CONFIG_ADDRESS: TestSCAddress = TestSCAddress::new("config-address");
const CONFIG_CODE_PATH: MxscPath = MxscPath::new("output/chain-config.mxsc.json");

const HEADER_VERIFIER_ADDRESS: TestSCAddress = TestSCAddress::new("header-verifier");

const OWNER: TestAddress = TestAddress::new("owner");
const OWNER_BALANCE: u64 = 100_000_000_000;

Expand Down Expand Up @@ -62,6 +64,22 @@ impl ChainConfigTestState {
transaction.run();
}
}

fn complete_setup_phase(&mut self, expect_error: Option<ExpectError>) {
let transaction = self
.world
.tx()
.from(OWNER)
.to(CONFIG_ADDRESS)
.typed(ChainConfigContractProxy)
.complete_setup_phase(HEADER_VERIFIER_ADDRESS);

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

#[test]
Expand Down Expand Up @@ -98,3 +116,13 @@ fn update_config_wrong_validators_array() {
Some(ExpectError(4, "Invalid min/max validator numbers")),
);
}

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

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

state.complete_setup_phase(None);
}

0 comments on commit 0fe84cf

Please sign in to comment.