pub(crate) fn test_force_deploy_upgrade<VM: TestedVm>() {
    let mut storage = get_empty_storage();
    let bytecode_hash = BytecodeHash::for_bytecode(TestContract::counter().bytecode).value();
    let known_code_key = get_known_code_key(&bytecode_hash);
    // It is generally expected that all the keys will be set as known prior to the protocol upgrade.
    storage.set_value(known_code_key, u256_to_h256(1.into()));

    let mut vm = VmTesterBuilder::new()
        .with_storage(storage)
        .with_execution_mode(TxExecutionMode::VerifyExecute)
        .with_rich_accounts(1)
        .build::<VM>();

    let address_to_deploy = Address::repeat_byte(1);
    // Here we just use some random transaction of protocol upgrade type:
    let transaction = get_forced_deploy_tx(&[ForceDeployment {
        // The bytecode hash to put on an address
        bytecode_hash,
        // The address on which to deploy the bytecode hash to
        address: address_to_deploy,
        // Whether to run the constructor on the force deployment
        call_constructor: false,
        // The value with which to initialize a contract
        value: U256::zero(),
        // The constructor calldata
        input: vec![],
    }]);

    vm.vm.push_transaction(transaction);

    let result = vm.vm.execute(InspectExecutionMode::OneTx);
    assert!(
        !result.result.is_failed(),
        "The force upgrade was not successful"
    );

    let expected_slots = [(
        get_code_key(&address_to_deploy),
        h256_to_u256(bytecode_hash),
    )];
    // Verify that the bytecode has been set correctly
    vm.vm.verify_required_storage(&expected_slots);
}
In this test we try to test how force deployments could be done via protocol upgrade transactions.
core/lib/multivm/src/versions/testonly/upgrade.rs