-
Notifications
You must be signed in to change notification settings - Fork 598
chore: test cli upgrade #12506
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
chore: test cli upgrade #12506
Changes from all commits
a5fa45d
0eaf5c2
05420a5
1f7499f
de78e1d
80c05d7
6fe20fe
e40bc3a
4e5c950
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { type PXE, createCompatibleClient } from '@aztec/aztec.js'; | ||
| import { GovernanceContract, RegistryContract, createEthereumChain, createL1Clients } from '@aztec/ethereum'; | ||
| import { createLogger } from '@aztec/foundation/log'; | ||
|
|
||
| import type { ChildProcess } from 'child_process'; | ||
|
|
||
| import { getAztecBin, isK8sConfig, runProjectScript, setupEnvironment, startPortForward } from './utils.js'; | ||
|
|
||
| const config = setupEnvironment(process.env); | ||
|
|
||
| // technically it doesn't require a k8s env, but it doesn't seem we're keeping the "local" versions of the spartan scripts up to date | ||
| // and I didn't want to plumb through the config and test this with the local scripts. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need the local scripts or would it make sense if anyway stale to kill em?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. @ludamad ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a team call, I asked recently and Sean gave feedback about using them, but I certainly don't right now. I'm a bit surprised that people don't find the interactive usage useful, but again your guy's call |
||
| if (!isK8sConfig(config)) { | ||
| throw new Error('This test must be run in a k8s environment'); | ||
| } | ||
|
|
||
| const debugLogger = createLogger('e2e:spartan-test:upgrade_via_cli'); | ||
|
|
||
| describe('upgrade via cli', () => { | ||
| let pxe: PXE; | ||
| const forwardProcesses: ChildProcess[] = []; | ||
| let ETHEREUM_HOSTS: string; | ||
| let MNEMONIC: string; | ||
| beforeAll(async () => { | ||
| let PXE_URL: string; | ||
| MNEMONIC = config.L1_ACCOUNT_MNEMONIC; | ||
| { | ||
| const { process, port } = await startPortForward({ | ||
| resource: `svc/${config.INSTANCE_NAME}-aztec-network-pxe`, | ||
| namespace: config.NAMESPACE, | ||
| containerPort: config.CONTAINER_PXE_PORT, | ||
| }); | ||
| forwardProcesses.push(process); | ||
| PXE_URL = `http://127.0.0.1:${port}`; | ||
| } | ||
| { | ||
| const { process, port } = await startPortForward({ | ||
| resource: `svc/${config.INSTANCE_NAME}-aztec-network-eth-execution`, | ||
| namespace: config.NAMESPACE, | ||
| containerPort: config.CONTAINER_ETHEREUM_PORT, | ||
| }); | ||
| forwardProcesses.push(process); | ||
| ETHEREUM_HOSTS = `http://127.0.0.1:${port}`; | ||
| } | ||
| pxe = await createCompatibleClient(PXE_URL, debugLogger); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this pr, but the |
||
| }); | ||
|
|
||
| afterAll(() => { | ||
| forwardProcesses.forEach(p => p.kill()); | ||
| }); | ||
|
|
||
| it( | ||
| 'should be able to get node enr', | ||
| async () => { | ||
| const info = await pxe.getNodeInfo(); | ||
|
|
||
| const chain = createEthereumChain([ETHEREUM_HOSTS], info.l1ChainId); | ||
| const { walletClient: l1WalletClient, publicClient: l1PublicClient } = createL1Clients( | ||
| [ETHEREUM_HOSTS], | ||
| MNEMONIC, | ||
| chain.chainInfo, | ||
| ); | ||
|
|
||
| const governance = new GovernanceContract( | ||
| info.l1ContractAddresses.governanceAddress.toString(), | ||
| l1PublicClient, | ||
| l1WalletClient, | ||
| ); | ||
| const { minimumVotes, proposeConfig } = await governance.getConfiguration(); | ||
|
|
||
| const depositAmount = proposeConfig.lockAmount + minimumVotes; | ||
|
|
||
| const registry = new RegistryContract(l1PublicClient, info.l1ContractAddresses.registryAddress.toString()); | ||
| const oldNumberOfVersions = await registry.getNumberOfVersions(); | ||
|
|
||
| const exitCode = await runProjectScript( | ||
| 'spartan/scripts/upgrade_rollup_with_lock.sh', | ||
| [ | ||
| '--aztec-bin', | ||
| getAztecBin(), | ||
| '--registry', | ||
| info.l1ContractAddresses.registryAddress.toString(), | ||
| '--address', | ||
| l1WalletClient.account.address, | ||
| '--deposit-amount', | ||
| depositAmount.toString(), | ||
| '--mint', | ||
| ], | ||
| debugLogger, | ||
| { | ||
| MNEMONIC, | ||
| ETHEREUM_HOSTS, | ||
| L1_CHAIN_ID: info.l1ChainId.toString(), | ||
| LOG_JSON: 'false', | ||
| LOG_LEVEL: 'debug', | ||
| }, | ||
| ); | ||
| expect(exitCode).toBe(0); | ||
|
|
||
| const newNumberOfVersions = await registry.getNumberOfVersions(); | ||
| expect(newNumberOfVersions).toBe(oldNumberOfVersions + 1); | ||
| }, | ||
| 6 * config.AZTEC_PROOF_SUBMISSION_WINDOW * config.AZTEC_SLOT_DURATION * 1000, | ||
| ); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great example of why CLI tests are good haha. Had a "don't know how to serialize bigint" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use the jsonStringify function in foundation