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

Validium fix test new env value #87

Merged
merged 9 commits into from
Feb 1, 2024
Merged
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
7 changes: 4 additions & 3 deletions core/tests/ts-integration/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ export async function scaledGasPrice(wallet: ethers.Wallet | zksync.Wallet): Pro
*
* @returns Boolean that indicates whether it is Validium mode.
*/
export async function getIsValidium(): Promise<boolean> {
export async function isValidium(): Promise<boolean> {

const filePath = `${process.env.ZKSYNC_HOME}/etc/env/dev.env`;

try {
const fileContent = await fs.promises.readFile(filePath, 'utf-8');

const isValidiumMode = fileContent
.split('\n')
.map((line) => line.trim().split('='))
Expand All @@ -127,4 +127,5 @@ export async function getIsValidium(): Promise<boolean> {
console.error(`Error reading or parsing the config file ${filePath}:`, error);
return false; // Return a default value or handle the error as needed
}
}
x}

4 changes: 2 additions & 2 deletions core/tests/ts-integration/tests/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { TestMaster } from '../src/index';
import { deployContract, getIsValidium, getTestContract, waitForNewL1Batch } from '../src/helpers';
import { deployContract, isValidium, getTestContract, waitForNewL1Batch } from '../src/helpers';
import { shouldOnlyTakeFee } from '../src/modifiers/balance-checker';

import * as ethers from 'ethers';
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('Smart contract behavior checks', () => {
});

// If it is running in validium mode, there is no pubdata and the transaction will not be rejected.
if (await getIsValidium()) {
if (await isValidium()) {
await expect(
alice.sendTransaction({
to: alice.address,
Expand Down
8 changes: 4 additions & 4 deletions core/tests/ts-integration/tests/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as ethers from 'ethers';
import { BigNumberish, BytesLike } from 'ethers';
import { serialize, hashBytecode } from 'zksync-web3/build/src/utils';
import { deployOnAnyLocalAddress, ForceDeployment } from '../src/system';
import { getIsValidium, getTestContract } from '../src/helpers';
import { isValidium, getTestContract } from '../src/helpers';

const contracts = {
counter: getTestContract('Counter'),
Expand Down Expand Up @@ -73,12 +73,12 @@ describe('System behavior checks', () => {
});

test('Should accept transactions with small gasPerPubdataByte', async () => {
const isValidium = await getIsValidium();
const isValidiumMode = await isValidium();
// The number "10" was chosen because we have a different error for lesser `smallGasPerPubdata`.
// In validium mode, this minimum value is "55"
const smallGasPerPubdata = isValidium ? 55 : 10;
const smallGasPerPubdata = isValidiumMode ? 55 : 10;
// In validium mode, the nonce is not required.
const senderNonce = isValidium ? undefined : await alice.getTransactionCount();
const senderNonce = isValidiumMode ? undefined : await alice.getTransactionCount();

// This tx should be accepted by the server, but would never be executed, so we don't wait for the receipt.
await alice.sendTransaction({
Expand Down
Loading