Skip to content

Commit

Permalink
test: add test for signMessage with a real client
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4karia committed Aug 27, 2024
1 parent 8fc7f21 commit 84b8961
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/newops/BtcNew.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ test("getWalletPublicKey p2wpkh", async () => {
test("testGetWalletPublicKeyRealClient p2wpkh", async () => {
await testGetWalletPublicKeyRealClient("m/84'/1'/0'", "wpkh(@0)");
});
test("testSignMessageRealClient", async () => {
await testSignMessageRealClient("m/84'/1'/0'");
});
test("getWalletPublicKey wrapped p2wpkh", async () => {
await testGetWalletPublicKey("m/49'/1'/0'", "sh(wpkh(@0))");
await testGetWalletPublicKey("m/49'/0'/17'", "sh(wpkh(@0))");
Expand Down Expand Up @@ -227,6 +230,30 @@ async function testGetWalletPublicKeyRealClient(
// verifyGetWalletPublicKeyResult(resultAccount, accountXpub);
}

async function testSignMessageRealClient(
accountPath: string,
) {
// try createTransportRecorder
const transport = await openTransportReplayer(RecordStore.fromString(`
=> e11000003605800000548000000180000000000000000000000004dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058e
<= 41dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058e0100e000
=> f801000022dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058e0000
<= 4000dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058ee000
=> f80100000705050074657374
<= 41dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058e0100e000
=> f801000022dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058e0000
<= 4000dbebd10e61bc8c28591273feafbbef95d544f874693301d8f7f8e54c6e30058ee000
=> f80100000705050074657374
<= 1f32af834dbf7e64f730a1fb76d1970cb66517222bfb017f46a75f91cc1fa216b76fd35df48d28b9c2c4b994e7799608cc1353ae810d1049a8ab8af047e16a1a999000
`));
const client = new AppClient(transport);
const path = accountPath + "/0/0";

const btcNew = new BtcNew(client);
const result = await btcNew.signMessage({ path: path, messageHex: Buffer.from("test").toString("hex") });
console.log('v,r,s: ', result)
}

function verifyGetWalletPublicKeyResult(
result: { publicKey: string; bitcoinAddress: string; chainCode: string },
expectedXpub: string,
Expand Down

0 comments on commit 84b8961

Please sign in to comment.