Skip to content
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

Adder: Add upgrade SC mandos test #1161

Merged
merged 7 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/examples/adder/tests/adder_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn world() -> ScenarioWorld {
}

#[test]
fn adder_mandos_constructed_raw() {
fn adder_blackbox_raw() {
let mut world = world();
let adder_code = world.code_expression(ADDER_PATH_EXPR);

Expand Down
50 changes: 50 additions & 0 deletions contracts/examples/adder/tests/adder_blackbox_upgrade_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use multiversx_sc_scenario::{scenario_model::*, *};

const ADDER_PATH_EXPR: &str = "file:output/adder.wasm";

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/adder");

blockchain.register_contract("file:output/adder.wasm", adder::ContractBuilder);
blockchain
}

#[test]
fn adder_blackbox_upgrade() {
let mut world = world();
let adder_code = world.code_expression(ADDER_PATH_EXPR);

world
.set_state_step(
SetStateStep::new()
.put_account("address:owner", Account::new().nonce(1))
.new_address("address:owner", 1, "sc:adder"),
)
.sc_deploy(
ScDeployStep::new()
.from("address:owner")
.code(&adder_code)
.argument("5")
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
)
.sc_call(
ScCallStep::new()
.from("address:owner")
.to("sc:adder")
.function("upgradeContract")
.argument(&adder_code)
.argument("0x0502") // codeMetadata
.argument("8") // contract argument
.expect(TxExpect::ok().no_result()),
)
.check_state_step(
CheckStateStep::new()
.put_account("address:owner", CheckAccount::new())
.put_account(
"sc:adder",
CheckAccount::new().check_storage("str:sum", "8"),
),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn world() -> ScenarioWorld {
}

#[test]
fn adder_scenario_constructed_raw() {
fn adder_blackbox_with_values() {
let mut world = world();
let owner_address = "address:owner";
let mut adder_contract = ContractInfo::<adder::Proxy<StaticApi>>::new("sc:adder");
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/adder/tests/adder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use multiversx_sc::types::BigUint;
use multiversx_sc_scenario::api::SingleTxApi;

#[test]
fn test_add() {
fn adder_unit_test() {
let adder = adder::contract_obj::<SingleTxApi>();

adder.init(BigUint::from(5u32));
Expand Down
Loading