Skip to content

Commit

Permalink
Merge pull request #1247 from input-output-hk/test/lw-10448-fix-faili…
Browse files Browse the repository at this point in the history
…ng-conway-era-tests

test(wallet): fix failing conway-era Ledger tests
  • Loading branch information
tomislavhoracek committed May 7, 2024
2 parents 0472faa + 25d6b91 commit b4abf94
Showing 1 changed file with 52 additions and 54 deletions.
106 changes: 52 additions & 54 deletions packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,6 @@ describe('LedgerKeyAgent', () => {

afterAll(() => wallet.shutdown());

let dRepPublicKey: Crypto.Ed25519PublicKeyHex;
let dRepKeyHash: Crypto.Ed25519KeyHashHex;

beforeEach(async () => {
dRepPublicKey = Crypto.Ed25519PublicKeyHex('b3691d42417d8307ad71da8586c2b439965545f481343b9073324ae60ad263f6');
dRepKeyHash = (await Crypto.Ed25519PublicKey.fromHex(dRepPublicKey).hash()).hex();
});

it('successfully signs a transaction with assets and validity interval', async () => {
const {
witness: { signatures }
Expand Down Expand Up @@ -292,52 +284,6 @@ describe('LedgerKeyAgent', () => {
expect(signatures.size).toBe(2);
});

it('can sign a transaction with voting procedures, treasury and donation', async () => {
const votingProcedure: Cardano.VotingProcedures[0] = {
voter: {
__typename: Cardano.VoterType.dRepKeyHash,
credential: { hash: Crypto.Hash28ByteBase16(dRepKeyHash), type: Cardano.CredentialType.KeyHash }
},
votes: [
{
actionId: {
actionIndex: 3,
id: Cardano.TransactionId('1000000000000000000000000000000000000000000000000000000000000000')
},
votingProcedure: {
anchor: {
dataHash: Crypto.Hash32ByteBase16('0000000000000000000000000000000000000000000000000000000000000000'),
url: 'https://www.someurl.io'
},
vote: 0
}
}
]
};

const txBuilder = wallet.createTxBuilder();
const builtTx = await txBuilder
.customize(({ txBody }) => {
const votingProcedures: Cardano.TxBody['votingProcedures'] = [
...(txBody.votingProcedures || []),
votingProcedure
];
return {
...txBody,
donation: 1000n,
treasuryValue: 2000n,
votingProcedures
};
})
.build()
.inspect();

const {
witness: { signatures }
} = await wallet.finalizeTx({ tx: builtTx });
expect(signatures.size).toBe(2);
});

it('can sign multi-delegation transaction', async () => {
const txBuilder = wallet.createTxBuilder();
const builtTx = await txBuilder
Expand All @@ -364,6 +310,15 @@ describe('LedgerKeyAgent', () => {

describe('conway-era', () => {
describe('ordinary tx mode', () => {
let dRepPublicKey: Crypto.Ed25519PublicKeyHex | undefined;
let dRepKeyHash: Crypto.Ed25519KeyHashHex;

beforeEach(async () => {
dRepPublicKey = await wallet.governance.getPubDRepKey();
if (!dRepPublicKey) throw new Error('No dRep pub key');
dRepKeyHash = (await Crypto.Ed25519PublicKey.fromHex(dRepPublicKey).hash()).hex();
});

it('can sign a transaction with Registration certs', async () => {
const txBuilder = wallet.createTxBuilder();
txBuilder.partialTxBody.certificates = [
Expand Down Expand Up @@ -669,6 +624,49 @@ describe('LedgerKeyAgent', () => {
InvalidDataReason.SIGN_MODE_ORDINARY__CERTIFICATE_DREP_CREDENTIAL_ONLY_AS_PATH
);
});

it('can sign a transaction with voting procedures, treasury and donation', async () => {
const votingProcedure: Cardano.VotingProcedures[0] = {
voter: {
__typename: Cardano.VoterType.dRepKeyHash,
credential: { hash: Crypto.Hash28ByteBase16(dRepKeyHash), type: Cardano.CredentialType.KeyHash }
},
votes: [
{
actionId: {
actionIndex: 3,
id: Cardano.TransactionId('1000000000000000000000000000000000000000000000000000000000000000')
},
votingProcedure: {
anchor: {
dataHash: Crypto.Hash32ByteBase16(
'0000000000000000000000000000000000000000000000000000000000000000'
),
url: 'https://www.someurl.io'
},
vote: 0
}
}
]
};

const txBuilder = wallet.createTxBuilder();
const builtTx = await txBuilder
.customize(({ txBody }) => {
const votingProcedures: Cardano.TxBody['votingProcedures'] = [
...(txBody.votingProcedures || []),
votingProcedure
];
return {
...txBody,
donation: 1000n,
treasuryValue: 2000n,
votingProcedures
};
})
.build();
expect(await builtTx.sign()).toBeTruthy();
});
});
});
});
Expand Down

0 comments on commit b4abf94

Please sign in to comment.