Repository navigation
feat: KMS-backed signer for the write path (createWithKms / initWithKms) #31
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| const std = @import("std"); | ||
| const sdk = @import("perpcity_sdk"); | ||
|
|
||
| const EthChainClient = sdk.chain_client.EthChainClient; | ||
|
|
||
| // The raw-key path constructs and tears down without a network call (the | ||
| // address derives locally from the key), so this regression-guards the | ||
| // `destroy` changes made for the KMS variant: the `kms_signer == null` branch | ||
| // must free cleanly under the testing allocator. | ||
| test "EthChainClient raw-key create/destroy is leak-clean and has no KMS signer" { | ||
| const alloc = std.testing.allocator; | ||
| const private_key = [_]u8{0x11} ** 32; | ||
|
|
||
| const ec = try EthChainClient.create(alloc, "http://localhost:8545", private_key); | ||
| defer ec.destroy(); | ||
|
|
||
| try std.testing.expect(ec.kms_signer == null); | ||
| try std.testing.expect(ec.kms_key_id == null); | ||
|
|
||
| // Address derivation is local (secp256k1), so this needs no node. | ||
| var cc = ec.client(); | ||
| const addr = try cc.address(); | ||
| var all_zero = true; | ||
| for (addr) |b| { | ||
| if (b != 0) { | ||
| all_zero = false; | ||
| break; | ||
| } | ||
| } | ||
| try std.testing.expect(!all_zero); | ||
| } | ||
|
|
||
| // The KMS constructors are referenced here so a signature change breaks the | ||
| // build. They are not invoked: KmsSigner.init calls kms:GetPublicKey (a network | ||
| // call needing AWS credentials), so the KMS signing path is exercised only by | ||
| // integration tests, not CI. | ||
| test "KMS constructors are wired (compile-time reference only)" { | ||
| const ctx_kms = @TypeOf(sdk.context.PerpCityContext.initWithKms); | ||
| const ec_kms = @TypeOf(EthChainClient.createWithKms); | ||
| try std.testing.expect(@typeInfo(ctx_kms) == .@"fn"); | ||
| try std.testing.expect(@typeInfo(ec_kms) == .@"fn"); | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.