Skip to content

Commit

Permalink
test: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jan 29, 2024
1 parent 796831a commit ff33e37
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ In the meantime, you can test the code manually by running the code in [developm
### CLI tests

To run CLI tests for zksync-cli do the following:
1. Go to [cli-tests](`./src/tests/cli-tests`) folder
1. Go to [test](`./test`) folder
2. Run `npm i` and install zksync-cli `npm i zksync-cli`
3. Make sure you have [Docker](https://docs.docker.com/engine/install/) on your system.
4. Make sure you have `.env` file with your wallet private key in `src\tests\cli-tests\src\` dir. Key is `E2E_TESTNET_PK`. It may looks like `E2E_TESTNET_PK=012345...abcdef`
4. Make sure you have `.env` file with your wallet private key in `./tests/src/` dir. Key is `E2E_TESTNET_PK`. It may looks like `E2E_TESTNET_PK=012345...abcdef`
5. Run `npm test`

## 🌍 Official Links
Expand Down
29 changes: 11 additions & 18 deletions test/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { adresses, contracts, wallet } from "./entities";
import { executeCommand } from "./helper";
import { adresses, contracts, wallet } from "./src/entities";
import { executeCommand } from "./src/helper";

//id1717
describe("Check version of package", () => {
Expand Down Expand Up @@ -104,32 +104,25 @@ describe("User can check installed modules", () => {
});

//id1869
xdescribe("Check wallet balance of specified address", () => {
describe("Check wallet balance of specified address", () => {
const partialCommand = "npx zksync-cli wallet balance";
it(`${partialCommand} | on Sepolia Testnet`, () => {
const command = `${partialCommand} --chain zksync-sepolia --address ${adresses.sepoliaTestnet}`;
it(`${partialCommand} | on Era Testnet`, () => {
const command = `${partialCommand} --chain era-testnet --address ${adresses.sepoliaTestnet}`;
const result = executeCommand(command);
expect(result.output).toMatch(/(zkSync Sepolia Testnet Balance:)/i);
expect(result.output).toMatch(/(Testnet Balance:)/i);
expect(result.exitCode).toBe(0);
});

it(`${partialCommand} | on zkSync Mainnet`, () => {
const command = `${partialCommand} --chain zksync-mainnet --address ${adresses.zksyncMainnet}`;
const command = `${partialCommand} --chain era-mainnet --address ${adresses.zksyncMainnet}`;
const result = executeCommand(command);
expect(result.output).toMatch(/(zkSync Mainnet Balance:)/i);
expect(result.exitCode).toBe(0);
});

it(`${partialCommand} | on Goerli Testnet`, () => {
const command = `${partialCommand} --chain zksync-goerli --address ${adresses.goerliTestnet}`;
const result = executeCommand(command);
expect(result.output).toMatch(/(zkSync Goerli Testnet Balance:)/i);
expect(result.output).toMatch(/(Mainnet Balance:)/i);
expect(result.exitCode).toBe(0);
});
});

//id1718
xdescribe("Specific package can be updated using zksync-cli dev update <module name>", () => {
describe("Specific package can be updated using zksync-cli dev update <module name>", () => {
// need to find out the way how to make "npx zksync-cli dev start"

it("npx zksync-cli dev update <module>", () => {
Expand All @@ -144,7 +137,7 @@ xdescribe("Specific package can be updated using zksync-cli dev update <module n
//id1874
xdescribe("User can call read method from deployed contract on network", () => {
it("npx zksync-cli contract read", () => {
const command = `npx zksync-cli contract read --chain zksync-sepolia\
const command = `npx zksync-cli contract read --chain era-testnet\
--contract ${contracts.sepoliaTestnet} --method "greet() view returns (string)"\
--output string`;
const result = executeCommand(command);
Expand All @@ -162,7 +155,7 @@ xdescribe("User can call write method from deployed contract on network", () =>
if (process.platform === "win32") {
optionalRedirection = " > nul ";
}
const command = `npx zksync-cli contract write --chain zksync-sepolia\
const command = `npx zksync-cli contract write --chain era-testnet\
--contract ${contracts.sepoliaTestnet} --method "setGreeting(string _greeting) "\
--args "New Test ARG" --private-key ${wallet.testnetPK} ${optionalRedirection}`; // potential issue. on windows without the redirection we catching a wrong stdout.
const result = executeCommand(command);
Expand Down
1 change: 0 additions & 1 deletion test/entities.ts → test/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dotenv.config(); // { path: path.resolve(__dirname, ".env") }
export const adresses = {
sepoliaTestnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46",
zksyncMainnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46",
goerliTestnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46",
};

export const contracts = {
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["./src"],
"exclude": ["**/cli-tests/**"]
"include": ["./src"]
}

0 comments on commit ff33e37

Please sign in to comment.