-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Check sandbox version matches CLI's (#1849)
Checks on every CLI command that the Aztec RPC server version matches the expected one. Checks exact matches for now, but can be extended to semver checks. If no match, emits a warn. ``` $ yarn aztec-cli get-accounts cli WARN Aztec Sandbox is running version 0.1.0 which is newer than the expected by this CLI (0.0.0). Consider upgrading your CLI to a newer version. Accounts found: Address: 0x2e13f0201905944184fc2c09d29fcf0cac07647be171656a275f63d99b819360, Public Key: 0x157922ba4defc5ccc36862afdf51dec2df3da3f683507ebffd59d472d6cbf0eb193a4e294e4fb994b22bd5dcb382b83b88734eef20e01a90f1498f9d60f0db8b, Partial Address: 0x044770258feb9223e966ae7bbae2b3a975d4a43e480688e7c51119ee4eb2e054 ``` To support this, the `NodeInfo` struct returned from the RPC server returns also the `client` identifier, which looks like `[email protected]`.
- Loading branch information
1 parent
2dae3f0
commit 7279730
Showing
15 changed files
with
165 additions
and
24 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
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,34 @@ | ||
import { AztecRPC, NodeInfo } from '@aztec/types'; | ||
|
||
import { MockProxy, mock } from 'jest-mock-extended'; | ||
|
||
import { checkServerVersion } from './client.js'; | ||
|
||
describe('client', () => { | ||
describe('checkServerVersion', () => { | ||
let rpc: MockProxy<AztecRPC>; | ||
|
||
beforeEach(() => { | ||
rpc = mock<AztecRPC>(); | ||
}); | ||
|
||
it('checks versions match', async () => { | ||
rpc.getNodeInfo.mockResolvedValue({ client: '[email protected]' } as NodeInfo); | ||
await checkServerVersion(rpc, '0.1.0-alpha47'); | ||
}); | ||
|
||
it('reports mismatch on older rpc version', async () => { | ||
rpc.getNodeInfo.mockResolvedValue({ client: '[email protected]' } as NodeInfo); | ||
await expect(checkServerVersion(rpc, '0.1.0-alpha48')).rejects.toThrowError( | ||
/is older than the expected by this CLI/, | ||
); | ||
}); | ||
|
||
it('reports mismatch on newer rpc version', async () => { | ||
rpc.getNodeInfo.mockResolvedValue({ client: '[email protected]' } as NodeInfo); | ||
await expect(checkServerVersion(rpc, '0.1.0-alpha47')).rejects.toThrowError( | ||
/is newer than the expected by this CLI/, | ||
); | ||
}); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.