Skip to content

Commit

Permalink
Validium fix test new env value (#87)
Browse files Browse the repository at this point in the history
* Fix tests using the new env var

* Fix file used

* Update validium environment

* Optimize code

* Remove unused imports

* update isValidium method

* update isValidium methos

* fix conflicts

---------

Co-authored-by: Jordi <[email protected]>
  • Loading branch information
toni-calvin and jorbush authored Feb 1, 2024
1 parent ea1c727 commit acdbf43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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

0 comments on commit acdbf43

Please sign in to comment.