Skip to content

Commit

Permalink
Update validium environment
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbush committed Jan 31, 2024
1 parent 4dd864c commit 5d88fab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
22 changes: 18 additions & 4 deletions core/tests/ts-integration/tests/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import * as ethers from 'ethers';
import * as zksync from 'zksync-web3';
import { Provider } from 'zksync-web3';
import { RetryProvider } from '../src/retry-provider';

const ENV_CONFIG = require(`${process.env.ENV_FILE!}`);
import { promises as fs } from 'fs';

// TODO: Leave only important ones.
const contracts = {
Expand All @@ -37,10 +36,25 @@ describe('Smart contract behavior checks', () => {

// Contracts shared in several tests.
let counterContract: zksync.Contract;
let is_validium: Boolean;

beforeAll(() => {
beforeAll(async () => {
testMaster = TestMaster.getInstance(__filename);
alice = testMaster.mainAccount();
const filePath = `${process.env.ZKSYNC_HOME}/etc/env/dev.env`;
try {
const fileContent = await fs.readFile(filePath, 'utf-8');
const keyValuePairs = fileContent.split('\n').map((line) => line.trim().split('='));
const configObject: { [key: string]: string } = {};
keyValuePairs.forEach((pair) => {
if (pair.length === 2) {
configObject[pair[0]] = pair[1];
}
});
is_validium = configObject.VALIDIUM_MODE === 'true';
} catch (error) {
console.error(`Error reading or parsing the config file ${filePath}:`, error);
}
});

test('Should deploy & call a contract', async () => {
Expand Down Expand Up @@ -322,7 +336,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 (ENV_CONFIG['VALIDIUM_MODE']) {
if (is_validium) {
await expect(
alice.sendTransaction({
to: alice.address,
Expand Down
24 changes: 19 additions & 5 deletions core/tests/ts-integration/tests/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,35 @@ import { BigNumberish, BytesLike } from 'ethers';
import { serialize, hashBytecode } from 'zksync-web3/build/src/utils';
import { deployOnAnyLocalAddress, ForceDeployment } from '../src/system';
import { getTestContract } from '../src/helpers';
import { promises as fs } from 'fs';

const contracts = {
counter: getTestContract('Counter'),
events: getTestContract('Emitter')
};

const ENV_CONFIG = require(`${process.env.ENV_FILE!}`);

describe('System behavior checks', () => {
let testMaster: TestMaster;
let alice: zksync.Wallet;
let is_validium: Boolean;

beforeAll(() => {
beforeAll(async () => {
testMaster = TestMaster.getInstance(__filename);
alice = testMaster.mainAccount();
const filePath = `${process.env.ZKSYNC_HOME}/etc/env/dev.env`;
try {
const fileContent = await fs.readFile(filePath, 'utf-8');
const keyValuePairs = fileContent.split('\n').map((line) => line.trim().split('='));
const configObject: { [key: string]: string } = {};
keyValuePairs.forEach((pair) => {
if (pair.length === 2) {
configObject[pair[0]] = pair[1];
}
});
is_validium = configObject.VALIDIUM_MODE === 'true';
} catch (error) {
console.error(`Error reading or parsing the config file ${filePath}:`, error);
}
});

test('Network should be supporting Cancun+Deneb', async () => {
Expand Down Expand Up @@ -77,8 +91,8 @@ describe('System behavior checks', () => {
test('Should accept transactions with small gasPerPubdataByte', async () => {
// The number "10" was chosen because we have a different error for lesser `smallGasPerPubdata`.
// In validium mode, this minimum value is "55"
const smallGasPerPubdata = ENV_CONFIG['VALIDIUM_MODE'] ? 55 : 10;
const senderNonce = ENV_CONFIG['VALIDIUM_MODE'] ? undefined : await alice.getTransactionCount();
const smallGasPerPubdata = is_validium ? 55 : 10;
const senderNonce = is_validium ? 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 5d88fab

Please sign in to comment.