Upgrading Contracts

Issue: When testing contract with oz-upgrades :

  1. Trying test for unsafe pattern (as intializing variable directly (not in constructor) as uint256 rad=90))
    When upgading ,then It will throw error ,but i'm not able to catch it .

:1234: Code to reproduce

Contract V0{
string public hello;
mapping(address=>string) mapString;
function setString(string memory _str)public {
mapString[msg.sender]=_str;
hello=_str;
}
}

Contract V1{

string public hello="roman";
mapping(address=>string) mapString;
function setString(string memory _str)public {
mapString[msg.sender]=_str;
hello=_str;
}
}

in test/test_upgrades.js

const { ethers ,upgrades} = require("hardhat");

describe("Upgrading Contract", async function () {
let proxy;
beforeEach(async () => {

const V0 = await ethers.getContractFactory("V0");
proxy = await upgrades.deployProxy(V0);

});

it("Shound not upgrade if initalizing hello in upgrading implementation contract", async () => {
  const V2 = await ethers.getContractFactory("V2");
   
 await  expect(upgrades.upgradeProxy(proxy.address ,V2)).to.throw()
});

:computer: Environment

Hardhat

Please use triple backticks to surround your code in order to get proper formatting.

```
code here
```

Your test is using contract V2 but you haven't included a V2 contract in the post.