Skip to content
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
25 changes: 25 additions & 0 deletions src/project-configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,31 @@ export const projectConfigs: ProjectConfigurations = {
}
],
replacements: {}
},{
name: "push",
title: "Push",
description: "A configuration with Push",
publish: true,
dependencies: [
{
name: "@pushchain/core",
version: "1.1.35",
import: true,
windowImport: true
},{
name: "ethers",
version: "^6",
alias: "ethersJS",
import: true,
windowImport: true,
},{
name: "bs58",
version: "6.0.0",
import: true,
windowImport: true
}
],
replacements: {}
}
// Add other projects here as needed
],
Expand Down
8 changes: 4 additions & 4 deletions test/src/tests/circom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = {
browser
//.clickLaunchIcon('filePanel')
.pause(2000)
.waitForElementVisible('*[data-id="workspacesMenuDropdown"]')
.click('*[data-id="workspacesMenuDropdown"]')
.waitForElementVisible('*[data-id="workspacesSelect"]')
.click('*[data-id="workspacesSelect"]')
.click('*[data-id="workspacecreate"]')
.waitForElementPresent('*[data-id="create-semaphore"]')
.scrollAndClick('*[data-id="create-semaphore"]')
Expand All @@ -39,7 +39,7 @@ module.exports = {
.click('[data-id="treeViewLitreeViewItemscripts/plonk/plonk_trusted_setup.ts"]')
.waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.click('[data-id="play-editor"]')
.click('[data-id="compile-action"]')
.waitForElementPresent({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(text(), 'plonk setup')]",
Expand All @@ -59,7 +59,7 @@ module.exports = {
.click('[data-id="treeViewLitreeViewItemscripts/plonk/plonk_zkproof.ts"]')
.waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.click('[data-id="play-editor"]')
.click('[data-id="compile-action"]')
.waitForElementPresent({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(text(), 'proof done')]",
Expand Down
4 changes: 2 additions & 2 deletions test/src/tests/crypto-aes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]')
.click('*[data-id="treeViewLitreeViewItemscripts"]')
.addFile('crypto-aes.ts', { content: testScript })
.waitForElementVisible('[data-id="play-editor"]')
.click('[data-id="play-editor"]')
.waitForElementVisible('[data-id="compile-action"]')
.click('[data-id="compile-action"]')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'aes-js functionality test PASSED!', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', 'crypto-js functionality test PASSED!', 60000)
}
Expand Down
28 changes: 28 additions & 0 deletions test/src/tests/push.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'

module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false, {
name: 'scriptRunner',
url: 'http://127.0.0.1:3000?template=push',
})
},
test: function (browser: NightwatchBrowser) {
browser
.addFile('test.ts', { content: testFile })
.executeScriptInTerminal('remix.execute("test.ts")')
.waitForElementContainsText('*[data-id="terminalJournal"]', '420000000000', 60000)
}
}

const testFile = `import { PushChain } from '@pushchain/core'

async function testPushCore() {
console.log(PushChain.utils.helpers.parseUnits('420', 9))
}

// Run the test
testPushCore()
`
16 changes: 8 additions & 8 deletions test/src/tests/terminal-ethers6.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const deploy = async (contractName: string, args: Array<any>, accountIndex?: num
console.log(\`deploying \${contractName}\`)
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = \`contracts/artifacts/\${contractName}.json\` // Change this for different path
const artifactsPath = \`artifacts/\${contractName}.json\` // Change this for different path

const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
Expand Down Expand Up @@ -204,7 +204,7 @@ const { expect } = require("chai");
describe("Storage with lib", function () {
it("test initial value", async function () {
// Make sure contract is compiled and artifacts are generated
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(0)
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -214,7 +214,7 @@ describe("Storage with lib", function () {
});

it("test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(0)
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -225,7 +225,7 @@ describe("Storage with lib", function () {
});

it("fail test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(0)
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand Down Expand Up @@ -282,7 +282,7 @@ const { ethers } = require("hardhat");

describe("Storage", function () {
it("test library integration by calling a lib method", async function () {
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Lib.json'))
console.log('deploying lib:')
const artifactLib = {
contractName: 'Lib',
Expand All @@ -299,7 +299,7 @@ describe("Storage", function () {
const lib = await factoryLib.deploy();
await lib.waitForDeployment()

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/StorageWithLib.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/StorageWithLib.json'))
const artifact = {
contractName: 'StorageWithLib',
sourceName: 'contracts/StorageWithLib.sol',
Expand Down Expand Up @@ -435,7 +435,7 @@ const scriptAutoExec = {

// function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;

const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/lib.json'))
console.log('deploying lib:')

const artifactLib = {
Expand All @@ -457,7 +457,7 @@ const scriptAutoExec = {

console.log('lib deployed', lib.address)

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Storage.json'))
const artifact = {
contractName: 'Storage',
sourceName: 'contracts/1_Storage.sol',
Expand Down
34 changes: 13 additions & 21 deletions test/src/tests/terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ module.exports = {

},

'Deploy "Owner" using an ether.js script, listen to event and check event are logged in the terminal #group4': function (browser: NightwatchBrowser) {
'compile-action, listen to event and check event are logged in the terminal #group4': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('solidity')
.click('.remixui_compilerConfigSection')
.setValue('#evmVersionSelector', 'london') // Set EVM version as fork version
.clickLaunchIcon('settings')
//.clickLaunchIcon('settings')
.clickLaunchIcon('udapp')
.switchEnvironment('vm-london')
.click('*[data-id="terminalClearConsole"]') // clear the terminal
.clickLaunchIcon('filePanel')
.click('*[data-id="treeViewUltreeViewMenu"]') // make sure we create the file at the root folder
Expand All @@ -110,20 +108,14 @@ module.exports = {
.click('[data-id="treeViewDivtreeViewItemcontracts"]')
.openFile('contracts/2_Owner.sol')
.clickLaunchIcon('solidity')
.waitForElementVisible('*[data-id="compilerContainerCompileBtn"]')
.click('*[data-id="compilerContainerCompileBtn"]').pause(5000) // compile Owner

.executeScriptInTerminal('remix.execute(\'deployWithEthersJs.js\')')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'Contract Address:', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', 'Deployment successful.', 60000)
.addAtAddressInstance('0xd9145CCE52D386f254917e481eB44e9943F39138', true, true, false)
.click('*[data-id="terminalClearConsole"]') // clear the terminal
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]', 60000)
.clickInstance(0)
.clickFunction('changeOwner - transact (not payable)', { types: 'address newOwner', values: '0xd9145CCE52D386f254917e481eB44e9943F39138' }) // execute the "changeOwner" function
.waitForElementContainsText('*[data-id="terminalJournal"]', 'previousOwner', 60000) // check that the script is logging the event
.waitForElementContainsText('*[data-id="terminalJournal"]', '0x5B38Da6a701c568545dCfcB03FcB875f56beddC4', 60000) // check that the script is logging the event
.waitForElementContainsText('*[data-id="terminalJournal"]', 'newOwner', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000)

},
'Run tests using Mocha script and check result logging in the terminal #group4': function (browser: NightwatchBrowser) {
browser
Expand Down Expand Up @@ -253,7 +245,7 @@ const deployWithEthersJs = `

// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = 'contracts/artifacts/Owner.json' // Change this for different path
const artifactsPath = 'artifacts/Owner.json' // Change this for different path

const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
Expand Down Expand Up @@ -286,7 +278,7 @@ const { expect } = require("chai");
describe("Storage with lib", function () {
it("test initial value", async function () {
// Make sure contract is compiled and artifacts are generated
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -296,7 +288,7 @@ describe("Storage with lib", function () {
});

it("test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -307,7 +299,7 @@ describe("Storage with lib", function () {
});

it("fail test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand Down Expand Up @@ -364,7 +356,7 @@ const { ethers } = require("hardhat");

describe("Storage", function () {
it("test library integration by calling a lib method", async function () {
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Lib.json'))
console.log('deploying lib:')
const artifactLib = {
contractName: 'Lib',
Expand All @@ -381,7 +373,7 @@ describe("Storage", function () {
const lib = await factoryLib.deploy();
await lib.deployed()

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/StorageWithLib.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/StorageWithLib.json'))
const artifact = {
contractName: 'StorageWithLib',
sourceName: 'contracts/StorageWithLib.sol',
Expand Down Expand Up @@ -517,7 +509,7 @@ const scriptAutoExec = {

// function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;

const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/lib.json'))
console.log('deploying lib:')

const artifactLib = {
Expand All @@ -539,7 +531,7 @@ const scriptAutoExec = {

console.log('lib deployed', lib.address)

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Storage.json'))
const artifact = {
contractName: 'Storage',
sourceName: 'contracts/1_Storage.sol',
Expand Down
6 changes: 3 additions & 3 deletions test/src/tests/ts-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]')
.click('*[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]')
.pause(2000)
.click('[data-id="play-editor"]')
.click('[data-id="compile-action"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]')
.click('*[data-id="treeViewLitreeViewItemscripts"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]')
.click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]')
.click('[data-id="play-editor"]')
.click('[data-id="compile-action"]')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'deploying Storage', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000)
},
'Should exec an ethers TS file': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]')
.click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]')
.click('[data-id="play-editor"]')
.click('[data-id="compile-action"]')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'deploying Storage', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8', 60000)
}
Expand Down
20 changes: 2 additions & 18 deletions test/src/tests/zk-sync-ethers6.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]')
.click('*[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]')
.pause(2000)
.click('*[data-id="play-editor"]') // run the script
.click('*[data-id="compile-action"]') // run the script
.pause(1000)
.clickLaunchIcon('udapp')
.waitForElementVisible('*[data-id="Deploy - transact (not payable)"]')
Expand All @@ -27,21 +27,12 @@ module.exports = {
browser
.addFile('zkSync.ts', { content: zkSync })
.executeScriptInTerminal('remix.execute("zkSync.ts")')
.waitForElementPresent({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(text(), 'test1:true')]",
timeout: 240000
})
.waitForElementPresent({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(text(), 'test2:true')]",
timeout: 240000
})
.waitForElementPresent({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(text(), 'test3:true')]",
timeout: 240000
})

},
}

Expand All @@ -54,18 +45,11 @@ import { Provider, types } from "zksync-ethers";
try {

const provider = Provider.getDefaultProvider(types.Network.Sepolia); // ZKsync Era testnet (L2)
const ethProvider = ethers.getDefaultProvider("sepolia"); // Sepolia testnet (L1)

const blockNumber = await provider.getBlockNumber();
const blocketh = await ethProvider.getBlockNumber();

console.log(\`test1:\${blocketh > 1}\`)
console.log(\`test2:\${blockNumber > 1}\`)

const ethersProvider = new ethers.BrowserProvider(web3Provider)
console.log(await ethersProvider.getBlockNumber())
console.log(\`test3:\${await ethersProvider.getBlockNumber() > 0}\`)

} catch (e) {
console.error('Error in script!')
console.error(e.message)
Expand Down