Skip to content

Commit 25cfea4

Browse files
author
ci-bot
committed
add uniswap test
1 parent 1579491 commit 25cfea4

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
'use strict'
2+
import { NightwatchBrowser } from 'nightwatch'
3+
import init from '../helpers/init'
4+
import sauce from './sauce'
5+
6+
module.exports = {
7+
'@disabled': true,
8+
before: function (browser: NightwatchBrowser, done: VoidFunction) {
9+
init(browser, done)
10+
},
11+
12+
'Should clone Uniswap v4-core repository #group1': function (browser: NightwatchBrowser) {
13+
browser
14+
.clickLaunchIcon('filePanel')
15+
.waitForElementVisible('*[data-id="github-dropdown-toggle"]')
16+
.click('*[data-id="github-dropdown-toggle"]')
17+
.waitForElementVisible('*[data-id="github-dropdown-item-clone"]')
18+
.click('*[data-id="github-dropdown-item-clone"]')
19+
.waitForElementVisible('[data-id="topbarModalModalDialogModalBody-react"]')
20+
.click('[data-id="topbarModalModalDialogModalBody-react"]')
21+
.waitForElementVisible('[data-id="modalDialogCustomPromptTextClone"]')
22+
.setValue('[data-id="modalDialogCustomPromptTextClone"]', 'https://github.com/Uniswap/v4-core')
23+
.click('[data-id="topbarModal-modal-footer-ok-react"]')
24+
.waitForElementPresent('.fa-spinner')
25+
.pause(5000)
26+
.waitForElementNotPresent('.fa-spinner', 240000)
27+
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]', 240000)
28+
.waitForElementContainsText('[data-id="workspacesSelect"]', 'v4-core')
29+
},
30+
31+
'Should verify repository was cloned with submodules #group1': function (browser: NightwatchBrowser) {
32+
browser
33+
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.gitmodules"]', 120000)
34+
.waitForElementVisible('[data-id="workspaceGitPanel"]')
35+
},
36+
37+
'Should update submodules in Remix interface #group1': function (browser: NightwatchBrowser) {
38+
browser
39+
.waitForElementVisible('[data-id="updatesubmodules"]', 120000)
40+
.click('[data-id="updatesubmodules"]')
41+
.waitForElementPresent('.fa-spinner')
42+
.waitForElementNotPresent('.fa-spinner', 240000)
43+
.pause(5000)
44+
},
45+
46+
'Should verify submodules are loaded #group1': function (browser: NightwatchBrowser) {
47+
browser
48+
// Verify that submodule directories exist (common submodules in v4-core)
49+
// The exact submodule names depend on the .gitmodules file
50+
// We'll check for the lib folder which typically contains submodules
51+
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemlib"]', 120000)
52+
.click('*[data-id="treeViewDivtreeViewItemlib"]')
53+
.pause(2000)
54+
},
55+
56+
'Should navigate to PoolManager.sol #group1': function (browser: NightwatchBrowser) {
57+
browser
58+
.pause(1000)
59+
// Navigate to src directory where PoolManager.sol is located
60+
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemsrc"]', 120000)
61+
.click('*[data-id="treeViewDivtreeViewItemsrc"]')
62+
.pause(2000)
63+
// Open PoolManager.sol
64+
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemsrc/PoolManager.sol"]', 120000)
65+
.click('*[data-id="treeViewDivtreeViewItemsrc/PoolManager.sol"]')
66+
.pause(2000)
67+
},
68+
69+
'Should verify PoolManager.sol is opened #group1': function (browser: NightwatchBrowser) {
70+
browser
71+
.pause(2000)
72+
.getEditorValue((content) => {
73+
browser.assert.ok(
74+
content.indexOf('contract PoolManager') !== -1 || content.indexOf('PoolManager') !== -1,
75+
'PoolManager.sol content should contain PoolManager contract'
76+
)
77+
})
78+
},
79+
80+
'Should set Solidity compiler version for v4-core #group1': function (browser: NightwatchBrowser) {
81+
browser
82+
.clickLaunchIcon('solidity')
83+
.pause(1000)
84+
// v4-core typically uses Solidity 0.8.x
85+
.setSolidityCompilerVersion('soljson-v0.8.26+commit.8a97fa7a.js')
86+
.waitForElementPresent({
87+
selector: `//*[@data-id='compilerloaded' and @data-version='soljson-v0.8.26+commit.8a97fa7a.js']`,
88+
locateStrategy: 'xpath',
89+
timeout: 120000
90+
})
91+
},
92+
93+
'Should compile PoolManager.sol #group1': function (browser: NightwatchBrowser) {
94+
browser
95+
.clickLaunchIcon('filePanel')
96+
.openFile('src/PoolManager.sol')
97+
.clickLaunchIcon('solidity')
98+
.pause(2000)
99+
.click('[data-id="compilerContainerCompileBtn"]')
100+
.pause(5000)
101+
},
102+
103+
'Should verify PoolManager.sol compilation #group1': function (browser: NightwatchBrowser) {
104+
browser
105+
.pause(5000)
106+
// Check that compilation completed - looking for PoolManager in compiled contracts
107+
.waitForElementVisible('*[data-id="compilation-details"]', 120000)
108+
.verifyContracts(['PoolManager'], { wait: 10000 })
109+
.pause(2000)
110+
},
111+
112+
'Should verify no compilation errors for PoolManager #group1': function (browser: NightwatchBrowser) {
113+
browser
114+
.clickLaunchIcon('solidity')
115+
.pause(2000)
116+
// Verify that PoolManager contract is available (compilation succeeded)
117+
// The contract should appear in the contract dropdown or compilation output
118+
.isVisible({
119+
selector: '*[data-id="compiledErrors"]',
120+
timeout: 5000,
121+
suppressNotFoundErrors: true
122+
})
123+
},
124+
125+
'Should create deployment script for PoolManager #group1': function (browser: NightwatchBrowser) {
126+
browser
127+
.clickLaunchIcon('filePanel')
128+
.click('*[data-id="treeViewUltreeViewMenu"]') // make sure we create the file at the root folder
129+
.addFile('deployPoolManager.js', { content: deployPoolManagerScript }, 'package.json')
130+
.pause(2000)
131+
},
132+
133+
'Should execute deployment script and verify contract address in terminal #group1': function (browser: NightwatchBrowser) {
134+
browser
135+
.click('*[data-id="run-script-dropdown-trigger"]')
136+
.click('*[data-id="run-with-ethers6-menu-item"]')
137+
.pause(5000)
138+
// Wait for the contract address to appear in the terminal output
139+
// Contract addresses start with 0x and are 42 characters long
140+
.waitForElementContainsText('*[data-id="terminalJournal"]', 'PoolManager deployed at:', 60000)
141+
.waitForElementContainsText('*[data-id="terminalJournal"]', '0x', 60000)
142+
.pause(2000)
143+
// Verify the deployment message appears in terminal
144+
.journalChildIncludes('PoolManager deployed at:')
145+
.journalChildIncludes('0x')
146+
}
147+
}
148+
149+
const deployPoolManagerScript = `
150+
import { ethers } from 'ethers'
151+
152+
/**
153+
* Deploy the PoolManager contract
154+
* @param {string} contractName name of the contract to deploy
155+
* @param {Array<any>} args list of constructor' parameters
156+
* @param {Number} accountIndex account index from the exposed account
157+
* @return {Contract} deployed contract
158+
*/
159+
const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {
160+
console.log(\`Deploying \${contractName}...\`)
161+
162+
// Note that the script needs the ABI which is generated from the compilation artifact.
163+
const artifactsPath = \`artifacts/\${contractName}.json\`
164+
165+
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
166+
167+
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
168+
169+
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
170+
171+
const contract = await factory.deploy(...args)
172+
173+
// Wait until the contract is deployed
174+
await contract.waitForDeployment()
175+
return contract
176+
}
177+
178+
(async () => {
179+
try {
180+
// Deploy PoolManager contract
181+
const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner()
182+
const poolManager = await deploy('PoolManager', [await signer.getAddress()])
183+
184+
const address = await poolManager.getAddress()
185+
console.log(\`PoolManager deployed at: \${address}\`)
186+
} catch (e) {
187+
console.log('Error deploying PoolManager:', e.message)
188+
}
189+
})()`

0 commit comments

Comments
 (0)