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: add additional tests for better coverage #633

Closed
Closed
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
58 changes: 51 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
cd packages/hardhat-zksync-vyper
yarn test

deploy:
examples:
runs-on: ubuntu-latest
name: deploy
name: examples
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -88,11 +88,11 @@ jobs:
yarn hardhat compile
yarn hardhat deploy-zksync

#- name: Test node example
# run: |
# cd examples/node-example
# yarn hardhat compile
# yarn hardhat test
- name: Test node example
run: |
cd examples/node-example
yarn hardhat compile
yarn hardhat test

- name: Test noninline libraries example
run: |
Expand Down Expand Up @@ -193,6 +193,7 @@ jobs:
run: |
cd packages/hardhat-zksync-upgradable
yarn test

verify-vyper:
runs-on: ubuntu-latest
name: verify-vyper
Expand All @@ -213,6 +214,7 @@ jobs:
run: |
cd packages/hardhat-zksync-verify-vyper
yarn test

verify:
runs-on: ubuntu-latest
name: verify
Expand All @@ -233,6 +235,47 @@ jobs:
run: |
cd packages/hardhat-zksync-verify
yarn test

deploy:
runs-on: ubuntu-latest
name: deploy
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2
with:
repository: matter-labs/local-setup
path: local-setup

- name: Run server
run: |
cd local-setup
./start.sh &>../server.log &

- uses: actions/setup-node@v2
with:
node-version: "16"
cache: yarn

- name: Setup environment
run: |
yarn install
yarn build

- name: Wait until server is up
run: |
while ! curl -s -X POST -d '{"jsonrpc":"2.0","method":"net_version","id":1}' -H 'Content-Type: application/json' 0.0.0.0:3050; do sleep 1; done

- name: Test deploy package
run: |
cd packages/hardhat-zksync-deploy
yarn test

- name: Show logs
if: always()
run: |
cat server.log

zksync-ethers:
runs-on: ubuntu-latest
name: zksync-ethers
Expand Down Expand Up @@ -272,6 +315,7 @@ jobs:
if: always()
run: |
cat server.log

node:
runs-on: ubuntu-latest
name: node
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ You can find more detailed explanations on how to use hardhat zkSync plugins on


We hope you find these plugins useful in your development efforts.\
Happy coding!🙌🎉\o/

Happy coding!🙌🎉
## License

hardhat-zkSync is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-zksync-deploy/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function callDeployScripts(hre: HardhatRuntimeEnvironment, targetSc
}
}
if (!found) {
console.error(`Script ${targetScript} was not found, no scripts were run`);
throw new ZkSyncDeployPluginError(`Script ${targetScript} was not found, no scripts were run`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
library ChildChildLib {

function plus(uint a, uint b) public pure returns (uint) {
return a - b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./ChildChildLib.sol";
library ChildLib {

using ChildChildLib for uint;

function plus(uint a, uint b) public view returns (uint, address) {
return (a.plus(b), address(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
library DLib {

function multiply(uint a, uint b) public view returns (uint, address) {
return (a * b, address(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./ChildLib.sol";
library Math2Lib {

using ChildLib for uint;

function multiply(uint a, uint b) public view returns (uint, address) {
return (a * b, address(this));
}

function plus(uint a, uint b) public view returns (uint, address) {
return a.plus(b);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./ChildLib.sol";
library MathLib {

using ChildLib for uint;

function multiply(uint a, uint b) public view returns (uint, address) {
return (a * b, address(this));
}

function plus(uint a, uint b) public view returns (uint, address) {
return a.plus(b);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./MathLib.sol";

contract TestCoin {

using MathLib for uint;
address owner = address(this);

function multiplyExample(uint _a, uint _b) public view returns (uint, address) {
return _a.multiply(_b);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import '@matterlabs/hardhat-zksync-deploy';
import '@matterlabs/hardhat-zksync-solc';

import { HardhatUserConfig } from 'hardhat/config';

const config: HardhatUserConfig = {
zksolc: {
settings: {
}
},
defaultNetwork: 'zkSyncNetwork',
networks: {
ethNetwork: {
url: 'http://0.0.0.0:8545',
},
zkSyncNetwork: {
url: 'http://0.0.0.0:3050',
ethNetwork: 'ethNetwork',
zksync: true,
accounts: {
//found in zksync-era github repo
mnemonic: "fine music test violin matrix prize squirrel panther purchase material script deal",
path: "m/44'/60'/0'/1",
initialIndex: 0,
count: 2,
},
},
},
// Docker image only works for solidity ^0.8.0.
// For earlier versions you need to use binary releases of zksolc.
solidity: {
version: '0.8.17',
},
};

export default config;

Large diffs are not rendered by default.

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;

contract Greeter {

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

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '../../../src/index';
import { HardhatUserConfig } from 'hardhat/types';
import { ETH_NETWORK_RPC_URL, ZKSYNC_NETWORK_NAME, ZKSYNC_NETWORK_RPC_URL } from '../../constants';

const config: HardhatUserConfig = {
networks: {
hardhat: {
zksync: true,
},
sepolia: {
url: ETH_NETWORK_RPC_URL,
},
[ZKSYNC_NETWORK_NAME]: {
url: ZKSYNC_NETWORK_RPC_URL,
ethNetwork: 'sepolia',
zksync: true,
},
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;
pragma abicoder v2;

contract Greeter {

string greeting;
string bad;
constructor(string memory _greeting) {
greeting = _greeting;
bad = "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad";
}

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { Wallet } from 'zksync-ethers';
import { Deployer } from '../../../../src/index';
import { WALLET_PRIVATE_KEY } from '../../../constants';
import chalk from 'chalk';

export default async function (hre: HardhatRuntimeEnvironment) {
const zkWallet = new Wallet(WALLET_PRIVATE_KEY);
const deployer = new Deployer(hre, zkWallet);
const artifact = await deployer.loadArtifact('Greeter');

console.info(chalk.yellow(`${artifact.contractName} was loaded`));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../../src/index';
import { HardhatUserConfig } from 'hardhat/types';
import { ETH_NETWORK_RPC_URL, ZKSYNC_NETWORK_NAME, ZKSYNC_NETWORK_RPC_URL } from '../../constants';

const config: HardhatUserConfig = {
networks: {
hardhat: {
zksync: true,
},
sepolia: {
url: ETH_NETWORK_RPC_URL,
},
[ZKSYNC_NETWORK_NAME]: {
url: ZKSYNC_NETWORK_RPC_URL,
ethNetwork: 'sepolia',
zksync: true,
},
},
solidity:{
version:'0.8.17'
}
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
library ChildChildLib {

function plus(uint a, uint b) public pure returns (uint) {
return a - b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./ChildChildLib.sol";
library ChildLib {

using ChildChildLib for uint;

function plus(uint a, uint b) public view returns (uint, address) {
return (a.plus(b), address(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
library DLib {

function multiply(uint a, uint b) public view returns (uint, address) {
return (a * b, address(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./ChildLib.sol";
library Math2Lib {

using ChildLib for uint;

function multiply(uint a, uint b) public view returns (uint, address) {
return (a * b, address(this));
}

function plus(uint a, uint b) public view returns (uint, address) {
return a.plus(b);
}
}
Loading
Loading