-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
336 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@celo/contractkit': minor | ||
--- | ||
|
||
Exposes EpochManager.getElectedSigners contract method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@celo/celocli': minor | ||
--- | ||
|
||
validator:signed-blocks not supported on L2 anymore, fixes validator:status L2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/cli/src/commands/validator/signed-blocks-l2.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { testWithAnvilL2 } from '@celo/dev-utils/lib/anvil-test' | ||
import Web3 from 'web3' | ||
import { testLocallyWithWeb3Node } from '../../test-utils/cliUtils' | ||
import ValidatorSignedBlocks from './signed-blocks' | ||
|
||
process.env.NO_SYNCCHECK = 'true' | ||
|
||
const KNOWN_DEVCHAIN_VALIDATOR = '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' | ||
|
||
testWithAnvilL2('validator:signed-blocks', (web3: Web3) => { | ||
it('shows unsupported message ', async () => { | ||
await expect( | ||
testLocallyWithWeb3Node(ValidatorSignedBlocks, ['--signer', KNOWN_DEVCHAIN_VALIDATOR], web3) | ||
).rejects.toMatchInlineSnapshot( | ||
`[Error: This command is not supported after CEL2 hardfork as the BFT consensus has been removed, see https://docs.celo.org/cel2/whats-changed/l1-l2 for more details]` | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { testWithAnvilL2 } from '@celo/dev-utils/lib/anvil-test' | ||
import { ux } from '@oclif/core' | ||
import Web3 from 'web3' | ||
import { stripAnsiCodesFromNestedArray, testLocallyWithWeb3Node } from '../../test-utils/cliUtils' | ||
import Switch from '../epochs/switch' | ||
import Status from './status' | ||
|
||
process.env.NO_SYNCCHECK = 'true' | ||
|
||
const KNOWN_DEVCHAIN_VALIDATOR = '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' | ||
|
||
testWithAnvilL2('validator:status', (web3: Web3) => { | ||
const writeMock = jest.spyOn(ux.write, 'stdout') | ||
const logMock = jest.spyOn(console, 'log') | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('displays status of the validator', async () => { | ||
await testLocallyWithWeb3Node( | ||
Status, | ||
['--validator', KNOWN_DEVCHAIN_VALIDATOR, '--csv', '--start', '349'], | ||
web3 | ||
) | ||
|
||
expect(stripAnsiCodesFromNestedArray(logMock.mock.calls)).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
"Running Checks:", | ||
], | ||
[ | ||
" ✔ 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f is a registered Account ", | ||
], | ||
[ | ||
" ✔ 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f is Validator ", | ||
], | ||
[ | ||
"All checks passed", | ||
], | ||
] | ||
`) | ||
expect(stripAnsiCodesFromNestedArray(writeMock.mock.calls)).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
"Address,Signer,Elected,Frontrunner | ||
", | ||
], | ||
[ | ||
"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,true,true | ||
", | ||
], | ||
] | ||
`) | ||
}) | ||
|
||
it('displays status for all validators', async () => { | ||
await testLocallyWithWeb3Node(Status, ['--all', '--csv', '--start', '349'], web3) | ||
|
||
expect(stripAnsiCodesFromNestedArray(logMock.mock.calls)).toMatchInlineSnapshot(`[]`) | ||
expect(stripAnsiCodesFromNestedArray(writeMock.mock.calls)).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
"Address,Signer,Elected,Frontrunner | ||
", | ||
], | ||
[ | ||
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65,0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65,true,true | ||
", | ||
], | ||
[ | ||
"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc,0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc,true,true | ||
", | ||
], | ||
[ | ||
"0x976EA74026E726554dB657fA54763abd0C3a0aa9,0x976EA74026E726554dB657fA54763abd0C3a0aa9,true,true | ||
", | ||
], | ||
[ | ||
"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955,0x14dC79964da2C08b23698B3D3cc7Ca32193d9955,true,true | ||
", | ||
], | ||
[ | ||
"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,true,true | ||
", | ||
], | ||
[ | ||
"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720,0xa0Ee7A142d267C1f36714E4a8F75612F20a79720,true,true | ||
", | ||
], | ||
] | ||
`) | ||
}) | ||
|
||
it('fails if start and end are in different epochs', async () => { | ||
const [account] = await web3.eth.getAccounts() | ||
|
||
await testLocallyWithWeb3Node(Switch, ['--from', account], web3) | ||
|
||
await expect( | ||
testLocallyWithWeb3Node( | ||
Status, | ||
['--validator', KNOWN_DEVCHAIN_VALIDATOR, '--start', '349'], | ||
web3 | ||
) | ||
).rejects.toThrowErrorMatchingInlineSnapshot( | ||
`"Start and end blocks must be in the current epoch"` | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.