Skip to content

Commit

Permalink
test: export governance voting keys
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Nov 27, 2022
1 parent 4a6ee2e commit cc7155f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
30 changes: 30 additions & 0 deletions test/integration/__fixtures__/getExtendedPublicKey.ts
Expand Up @@ -103,3 +103,33 @@ export const testsColdKeys: TestCase[] = [
},
},
]

export const testsGovernanceVotingKeys: TestCase[] = [
{
path: "1694'/1815'/0'/0/1",
expected: {
publicKey:
"aac861247bd24cae705bca1d1c9763f19c19188fb0faf257c50ed69b8157bced",
chainCode:
"f23595dd3207b7dde477347fa25d3fd6291c3363df43b54a9cf523d2c7683c10",
},
},
{
path: "1694'/1815'/100'",
expected: {
publicKey:
"ff451db773898b80488d892b248acdc634f6ec79d923f12aae9feb2563513b63",
chainCode:
"47478097ef56dcef686f8dcbd7d0c1d073740cde65a48e5615799096f67a144f",
},
},
{
path: "1694'/1815'/101'",
expected: {
publicKey:
"c7adc69b6dd29c48d29edb089c1aecbe218fdb9cfa59c325afcd2c5fa3844be1",
chainCode:
"ffa9953f6c77fccc15c000db494177d84e218f2740ddd44cfcbea0455cc6a6be",
},
},
]
22 changes: 20 additions & 2 deletions test/integration/getExtendedPublicKey.test.ts
Expand Up @@ -5,7 +5,8 @@ import type Ada from "../../src/Ada"
import { DeviceStatusError } from "../../src/Ada"
import { str_to_path } from "../../src/utils/address"
import { getAda } from "../test_utils"
import type { TestCase } from "./__fixtures__/getExtendedPublicKey"
import type { TestCase} from "./__fixtures__/getExtendedPublicKey"
import { testsGovernanceVotingKeys } from "./__fixtures__/getExtendedPublicKey"
import { testsByron, testsColdKeys, testsShelleyUnusual, testsShelleyUsual } from "./__fixtures__/getExtendedPublicKey"
chai.use(chaiAsPromised)

Expand Down Expand Up @@ -44,6 +45,9 @@ describe("getExtendedPublicKey", async () => {
it('get a single extended public key --- cold keys', async () => {
await test(testsColdKeys)
})
it('get a single extended public key --- governance voting keys', async () => {
await test(testsGovernanceVotingKeys)
})
})

describe("Should successfully get several extended public keys", async () => {
Expand All @@ -60,7 +64,7 @@ describe("getExtendedPublicKey", async () => {
}

it('starting with a usual one', async () => {
await test([...testsByron, ...testsShelleyUsual, ...testsColdKeys])
await test([...testsByron, ...testsShelleyUsual, ...testsColdKeys, ...testsGovernanceVotingKeys])
})

it('starting with an unusual one', async () => {
Expand All @@ -78,5 +82,19 @@ describe("getExtendedPublicKey", async () => {
const promise = ada.getExtendedPublicKey({ path: str_to_path("1853'/1900'/0'/0/0") })
await expect(promise).to.be.rejectedWith(DeviceStatusError, "Action rejected by Ledger's security policy")
})

// governance voting
it('invalid governance voting key path 1', async () => {
const promise = ada.getExtendedPublicKey({ path: str_to_path("1694'/1815'/0'/1/0") })
await expect(promise).to.be.rejectedWith(DeviceStatusError, "Action rejected by Ledger's security policy")
})
it('invalid governance voting key path 2', async () => {
const promise = ada.getExtendedPublicKey({ path: str_to_path("1694'/1815'/17") })
await expect(promise).to.be.rejectedWith(DeviceStatusError, "Action rejected by Ledger's security policy")
})
it('invalid governance voting key path 3', async () => {
const promise = ada.getExtendedPublicKey({ path: str_to_path("1694'/1815'/0'/1") })
await expect(promise).to.be.rejectedWith(DeviceStatusError, "Action rejected by Ledger's security policy")
})
})
})

0 comments on commit cc7155f

Please sign in to comment.