Skip to content

Commit

Permalink
Fixing unit tests for new derivation path indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
andborges committed Oct 18, 2023
1 parent 9dd90fc commit 7ae1a68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/keyring/tests/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Keyring create tests", () => {
const keyring = new KeyRing(storage);
await keyring.init(password, { mnemonic: MNEMONIC });
const keyAdd: KeyRecordAdd = {
basePath: "m/44'/626'/0'/0'",
basePath: "m/44'/626'/0'/0'/0'",
signerType: SignerType.ed25519kda,
name: "0index",
walletType: WalletType.mnemonic,
Expand All @@ -26,7 +26,7 @@ describe("Keyring create tests", () => {
expect(pair.signerType).equals(SignerType.ed25519kda);
expect(pair.pathIndex).equals(0);
expect(pair.address).equals(
"0xd75b971cc4846f543caa92e9bf07bf2f4cee87774f4ba8db2fde5c3dacaed03f"
"0x7359492db65e4e6487134cd68d5620e011965ce50c84f38e613c7bdb47c2bfa3"
);
keyring.lock();
}).timeout(20000);
Expand Down
16 changes: 5 additions & 11 deletions packages/signers/kadena/tests/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,27 @@ describe("Kadena address generate", () => {
const kadenaSigner = new Signer();

// Act & Assert
let keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0");
let keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0'/0");
expect(keypair.address).equals(
"0x7a3931f9379b5b63c76d73e3d79efbc890f56cfb22f1505ad457b7d0fb025f6d"
);

// Act & Assert
keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0'/0");
expect(keypair.address).equals(
"0x46e43dc208df46dfcc0662777f23dd8853079e3e0e8e2a31abc816cfbf55ea55"
"0x40a9305bd53a921c44cf19dc9bac4e5d73465fc6a46343ab313defe6b0bfb0a3"
);

// Act & Assert
keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0'/1");
expect(keypair.address).equals(
"0x07a9263d75d8debb5dcaebf679d09d1291111ebdc4eaaee73992dc0401e10e04"
"0x50d824cb62578b1fcf8e4afb122e98884d5f04070950b93a102e1ba1e1f3d1bb"
);

// Act & Assert
keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0'/2");
expect(keypair.address).equals(
"0xc1937f9eca305cdd048ad5785aaf1ad168b04d565250f6cd6e550c6d957e00b3"
"0x287b9cdbd0894fbff67c664b4cc1e7da9eca9b03ef94fd5baa2cfabe2cd3c6a5"
);

// Act & Assert
keypair = await kadenaSigner.generate(MNEMONIC, "m/44'/626'/0'/0'/3");
expect(keypair.address).equals(
"0x0d7f186afcd0759cd509de3741d609d3465aa65d74d0393410ad4a137252295d"
"0xe00a31c57aabe95554ad71c700c723153c0dd67b072b569916209138e419c122"
);
});
});
4 changes: 2 additions & 2 deletions packages/signers/kadena/tests/sign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ describe("Kadena signing", () => {
"Everything should be made as simple as possible, but not simpler.";
const msgHash = bufferToHex(blake2AsU8a(msg));
const signature =
"0x5c23909b5b05854e79410777abd0ce3145c47defb5e7a32a887c617a28cb63c52ad22ecbc72dc87118eb7854fe3115fe1b47490364b2a240ce400cdc516ff70e";
"0x8fd01eccc203d17cbffe54393954c213fb087dd6e62cf3c50bc5635346a83d9fae80c214ecb20bab092a0eca10408223e6e1007f597a3d4bfb525d68a0573a05";

const txMsg =
'{"payload":{"exec":{"code":"(coin.transfer-create \\"k:e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291\\" \\"k:e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291\\" (read-keyset \\"ks\\") 0.000000000000)","data":{"ks":{"keys":["e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291"],"pred":"keys-all"}}}},"nonce":"kjs:nonce:1696630965601","signers":[{"pubKey":"e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291","scheme":"ED25519","clist":[{"name":"coin.TRANSFER","args":["k:e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291","k:e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291",{"decimal":"0"}]},{"name":"coin.GAS","args":[]}]}],"meta":{"gasLimit":2500,"gasPrice":1e-8,"sender":"k:e84affbb41a62d74020bc4841ea206aba7734f9e0d30fb688a4a84fe2d30e291","ttl":28800,"creationTime":1696630965,"chainId":"1"},"networkId":"testnet04"}';

const txMsgSig =
"0xef8e48c609cd3f47852265785cc024900ee057eb766384292799f0cda38bf07839cff8aacd79581958f721098edb278ef92d112cdf1b623c69fde55b853af602";
"0xe929eecf16d77016646a95448fd24de3183488a5e4ab7ae0b1fcb5971fd6e3a524a6cc2879b2369e40f827b816355dbaad09b173442742c39ba487c68199a302";
it("it should sign correctly", async () => {
// Arrange
const kadenaSigner = new Signer();
Expand Down

0 comments on commit 7ae1a68

Please sign in to comment.