-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ (signer-eth) [DSDK-529]: Add missing TU for generic parser (#531)
- Loading branch information
Showing
11 changed files
with
669 additions
and
23 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 @@ | ||
--- | ||
"@ledgerhq/device-signer-kit-ethereum": patch | ||
--- | ||
|
||
Return an error if StartTransaction cmd does not contain a signature |
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 @@ | ||
--- | ||
"@ledgerhq/device-signer-kit-ethereum": patch | ||
--- | ||
|
||
Update error message for invalid chaincode |
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
88 changes: 82 additions & 6 deletions
88
packages/signer/signer-eth/src/internal/app-binder/command/ProvideEnumCommand.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 |
---|---|---|
@@ -1,15 +1,91 @@ | ||
import { | ||
type ApduResponse, | ||
isSuccessCommandResult, | ||
UnknownDeviceExchangeError, | ||
} from "@ledgerhq/device-management-kit"; | ||
|
||
import { | ||
ProvideEnumCommand, | ||
type ProvideEnumCommandArgs, | ||
} from "./ProvideEnumCommand"; | ||
|
||
describe("ProvideEnumCommand", () => { | ||
describe("getApdu", () => { | ||
it("", () => { | ||
// TODO: Implement test | ||
expect(true).toBe(true); | ||
it("should return the raw APDU for the first chunk", () => { | ||
// GIVEN | ||
const args: ProvideEnumCommandArgs = { | ||
data: Uint8Array.from([0x01, 0x02, 0x03]), | ||
isFirstChunk: true, | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideEnumCommand(args); | ||
const apdu = command.getApdu(); | ||
|
||
// THEN | ||
expect(apdu.getRawApdu()).toStrictEqual( | ||
Uint8Array.from([0xe0, 0x24, 0x01, 0x00, 0x03, 0x01, 0x02, 0x03]), | ||
); | ||
}); | ||
|
||
it("should return the raw APDU for the subsequent chunk", () => { | ||
// GIVEN | ||
const args: ProvideEnumCommandArgs = { | ||
data: Uint8Array.from([0x04, 0x05, 0x06]), | ||
isFirstChunk: false, | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideEnumCommand(args); | ||
const apdu = command.getApdu(); | ||
|
||
// THEN | ||
expect(apdu.getRawApdu()).toStrictEqual( | ||
Uint8Array.from([0xe0, 0x24, 0x00, 0x00, 0x03, 0x04, 0x05, 0x06]), | ||
); | ||
}); | ||
}); | ||
|
||
describe("parseResponse", () => { | ||
it("", () => { | ||
// TODO: Implement test | ||
expect(true).toBe(true); | ||
it("should return an error if the response status code is invalid", () => { | ||
// GIVEN | ||
const response: ApduResponse = { | ||
data: Uint8Array.from([]), | ||
statusCode: Uint8Array.from([0x6d, 0x00]), // Invalid status code | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideEnumCommand({ | ||
data: new Uint8Array(0), | ||
isFirstChunk: true, | ||
}); | ||
const result = command.parseResponse(response); | ||
|
||
// THEN | ||
if (isSuccessCommandResult(result)) { | ||
throw new Error("Expected an error"); | ||
} else { | ||
expect(result.error).toBeDefined(); | ||
expect(result.error).toBeInstanceOf(UnknownDeviceExchangeError); | ||
} | ||
}); | ||
|
||
it("should return a success result if the response status code is valid", () => { | ||
// GIVEN | ||
const response: ApduResponse = { | ||
data: Uint8Array.from([]), | ||
statusCode: Uint8Array.from([0x90, 0x00]), // Success status code | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideEnumCommand({ | ||
data: new Uint8Array(0), | ||
isFirstChunk: true, | ||
}); | ||
const result = command.parseResponse(response); | ||
|
||
// THEN | ||
expect(isSuccessCommandResult(result)).toBe(true); | ||
}); | ||
}); | ||
}); |
92 changes: 86 additions & 6 deletions
92
...ner-eth/src/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.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 |
---|---|---|
@@ -1,15 +1,95 @@ | ||
import { | ||
type ApduResponse, | ||
isSuccessCommandResult, | ||
UnknownDeviceExchangeError, | ||
} from "@ledgerhq/device-management-kit"; | ||
|
||
import { | ||
ProvideTransactionFieldDescriptionCommand, | ||
type ProvideTransactionFieldDescriptionCommandArgs, | ||
} from "./ProvideTransactionFieldDescriptionCommand"; | ||
|
||
describe("ProvideTransactionFieldDescriptionCommand", () => { | ||
describe("getApdu", () => { | ||
it("", () => { | ||
// TODO: Implement test | ||
expect(true).toBe(true); | ||
it("should return the raw APDU for the first chunk", () => { | ||
// GIVEN | ||
const args: ProvideTransactionFieldDescriptionCommandArgs = { | ||
data: Uint8Array.from([0x01, 0x02, 0x03]), | ||
isFirstChunk: true, | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideTransactionFieldDescriptionCommand(args); | ||
const apdu = command.getApdu(); | ||
|
||
// THEN | ||
expect(apdu.getRawApdu()).toStrictEqual( | ||
Uint8Array.from([0xe0, 0x28, 0x01, 0x00, 0x03, 0x01, 0x02, 0x03]), | ||
); | ||
}); | ||
|
||
it("should return the raw APDU for the subsequent chunk", () => { | ||
// GIVEN | ||
const args: ProvideTransactionFieldDescriptionCommandArgs = { | ||
data: Uint8Array.from([0x04, 0x05, 0x06]), | ||
isFirstChunk: false, | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideTransactionFieldDescriptionCommand(args); | ||
const apdu = command.getApdu(); | ||
|
||
// THEN | ||
expect(apdu.getRawApdu()).toStrictEqual( | ||
Uint8Array.from([0xe0, 0x28, 0x00, 0x00, 0x03, 0x04, 0x05, 0x06]), | ||
); | ||
}); | ||
}); | ||
|
||
describe("parseResponse", () => { | ||
it("", () => { | ||
// TODO: Implement test | ||
expect(true).toBe(true); | ||
it("should return an error if the response status code is invalid", () => { | ||
// GIVEN | ||
const response: ApduResponse = { | ||
data: Uint8Array.from([]), | ||
statusCode: Uint8Array.from([0x6d, 0x00]), // Invalid status code | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideTransactionFieldDescriptionCommand({ | ||
data: new Uint8Array(0), | ||
isFirstChunk: true, | ||
}); | ||
const result = command.parseResponse(response); | ||
|
||
// THEN | ||
if (isSuccessCommandResult(result)) { | ||
throw new Error("Expected an error"); | ||
} else { | ||
expect(result.error).toBeDefined(); | ||
expect(result.error).toBeInstanceOf(UnknownDeviceExchangeError); | ||
} | ||
}); | ||
|
||
it("should return a success result if the response status code is valid", () => { | ||
// GIVEN | ||
const response: ApduResponse = { | ||
data: Uint8Array.from([]), | ||
statusCode: Uint8Array.from([0x90, 0x00]), // Success status code | ||
}; | ||
|
||
// WHEN | ||
const command = new ProvideTransactionFieldDescriptionCommand({ | ||
data: new Uint8Array(0), | ||
isFirstChunk: true, | ||
}); | ||
const result = command.parseResponse(response); | ||
|
||
// THEN | ||
if (!isSuccessCommandResult(result)) { | ||
throw new Error("Expected a success result"); | ||
} else { | ||
expect(result.data).toBeUndefined(); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.