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

chore: update e2e to include tests for hardhat-zksync plugin #1006

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions e2e/fixture-projects/compatability-check/preprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ cat <<EOF > "$SCRIPT_DIR/package.json"
"typescript": "^5.1.6"
},
"dependencies": {
"@matterlabs/hardhat-zksync-deploy": "0.8.0",
"@matterlabs/hardhat-zksync-solc": "1.1.4",
"@matterlabs/hardhat-zksync-node": "0.1.0",
"@matterlabs/hardhat-zksync-upgradable": "0.3.1",
"hardhat": "^2.19.4",
"@matterlabs/hardhat-zksync-deploy": "^0.9.0",
"@matterlabs/hardhat-zksync-solc": "^1.1.4",
"@matterlabs/hardhat-zksync-node": "^0.1.0",
"@matterlabs/hardhat-zksync-upgradable": "^0.4.0",
"hardhat": "^2.14.0",
"ethers": "^5.7.2",
"zksync-ethers": "^5.0.0",
"@matterlabs/zksync-contracts": "^0.6.1",
Expand Down
10 changes: 10 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Bar.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v2;

import "./Foo.sol";

contract Bar {
Foo public foo = new Foo();
}
27 changes: 27 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Box.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract Box is Initializable {
uint256 private value;
uint256 private secondValue;
uint256 private thirdValue;

function initialize(uint256 initValue) public initializer {
value = initValue;
}

// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}

// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}
// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
}
33 changes: 33 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/BoxUups.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

contract BoxUups is Initializable, UUPSUpgradeable, OwnableUpgradeable {
uint256 private value;
uint256 private secondValue;
uint256 private thirdValue;

function initialize(uint256 initValue) public initializer {
value = initValue;
__Ownable_init();
__UUPSUpgradeable_init();
}

// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}

// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}

function _authorizeUpgrade(address) internal override onlyOwner {}

// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
}
54 changes: 54 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/BoxUupsV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

contract BoxUupsV2 is Initializable, UUPSUpgradeable, OwnableUpgradeable {
uint256 private value;
uint256 private secondValue;
uint256 private thirdValue;

function initialize(uint256 initValue) public initializer {
value = initValue;
}

// Reads the last stored value and returns it with a prefix
function retrieve() public view returns (string memory) {
return string(abi.encodePacked('V2: ', uint2str(value)));
}

// Converts a uint to a string
function uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return '0';
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}

// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}

function _authorizeUpgrade(address) internal override onlyOwner {}

// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
}
51 changes: 51 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/BoxV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract BoxV2 is Initializable{
uint256 private value;
uint256 private secondValue;
uint256 private thirdValue;

// Emitted when the stored value changes
event ValueChanged(uint256 newValue);

function initialize(uint256 initValue) public initializer {
value = initValue;
}

// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}

// Reads the last stored value and returns it with a prefix
function retrieve() public view returns (string memory) {
return string(abi.encodePacked("V2: ", uint2str(value)));
}

// Converts a uint to a string
function uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
}
7 changes: 7 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Empty.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v2;

contract Empty {
}
8 changes: 8 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Foo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v2;

contract Foo {
string public name = "Foo";
}
19 changes: 19 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v2;

contract Greeter {
string greeting;
constructor(string memory _greeting) {
greeting = _greeting;
}

function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public {
greeting = _greeting;
}
}
17 changes: 17 additions & 0 deletions e2e/fixture-projects/hardhat-zksync/contracts/Import.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma abicoder v2;

// import Foo.sol from current directory
import "./Bar.sol";

contract Import {
// Initialize Bar
Bar public bar = new Bar();

// Test Foo.sol by getting it's name.
function getFooName() public view returns (string memory) {
return bar.foo().name();
}
}
Loading
Loading