crypto: Add tests for convenience hash functions
This commit is contained in:
parent
53d7d34b8a
commit
0a1da22fb4
@ -1,6 +1,6 @@
|
||||
import { fromHex, toHex } from "@cosmjs/encoding";
|
||||
|
||||
import { Keccak256 } from "./keccak";
|
||||
import { Keccak256, keccak256 } from "./keccak";
|
||||
import keccakVectors from "./testdata/keccak.json";
|
||||
|
||||
describe("Keccak256", () => {
|
||||
@ -25,4 +25,9 @@ describe("Keccak256", () => {
|
||||
expect(new Keccak256(fromHex(input)).digest()).toEqual(fromHex(output));
|
||||
}
|
||||
});
|
||||
|
||||
it("exposes a convenience function", () => {
|
||||
const { in: input, out: output } = keccakVectors.keccak256[0];
|
||||
expect(keccak256(fromHex(input))).toEqual(fromHex(output));
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { fromHex } from "@cosmjs/encoding";
|
||||
|
||||
import { Ripemd160 } from "./ripemd";
|
||||
import { Ripemd160, ripemd160 } from "./ripemd";
|
||||
import ripemdVectors from "./testdata/ripemd.json";
|
||||
|
||||
describe("Ripemd160", () => {
|
||||
@ -25,4 +25,9 @@ describe("Ripemd160", () => {
|
||||
expect(new Ripemd160(fromHex(input)).digest()).toEqual(fromHex(output));
|
||||
}
|
||||
});
|
||||
|
||||
it("exposes a convenience function", () => {
|
||||
const { in: input, out: output } = ripemdVectors.ripemd160[0];
|
||||
expect(ripemd160(fromHex(input))).toEqual(fromHex(output));
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { fromHex, toHex } from "@cosmjs/encoding";
|
||||
|
||||
import { Sha256 } from "./sha";
|
||||
import { Sha256, sha256 } from "./sha";
|
||||
import shaVectors from "./testdata/sha.json";
|
||||
|
||||
describe("Sha256", () => {
|
||||
@ -25,4 +25,9 @@ describe("Sha256", () => {
|
||||
expect(new Sha256(fromHex(input)).digest()).toEqual(fromHex(output));
|
||||
}
|
||||
});
|
||||
|
||||
it("exposes a convenience function", () => {
|
||||
const { in: input, out: output } = shaVectors.sha256[0];
|
||||
expect(sha256(fromHex(input))).toEqual(fromHex(output));
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user