Skip to content

Commit

Permalink
Merge pull request cosmos#71 from confio/rm-unused
Browse files Browse the repository at this point in the history
Remove unused encoding code; move helpers to test code only
  • Loading branch information
ethanfrey authored Jan 31, 2022
2 parents 40f5d37 + 7786b70 commit a48c323
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/src/ops.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ics23 } from "./generated/codecimpl";

import { fromHex, toAscii } from "./helpers";
import { applyInner, applyLeaf, doHash } from "./ops";
import { fromHex, toAscii } from "./testhelpers.spec";

describe("doHash", () => {
it("sha256 hashes food", () => {
Expand Down
2 changes: 1 addition & 1 deletion js/src/proofs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ics23 } from "./generated/codecimpl";

import { fromHex, toAscii } from "./helpers";
import { calculateExistenceRoot, ensureSpec, iavlSpec } from "./proofs";
import { fromHex, toAscii } from "./testhelpers.spec";

describe("calculateExistenceRoot", () => {
it("must have at least one step", () => {
Expand Down
18 changes: 0 additions & 18 deletions js/src/helpers.ts → js/src/testhelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,3 @@ export function toAscii(input: string): Uint8Array {
});
return Uint8Array.from(toNums(input));
}

export function fromAscii(data: Uint8Array): string {
const fromNums = (listOfNumbers: ReadonlyArray<number>) =>
listOfNumbers.map((x: number): string => {
// 0x00–0x1F control characters
// 0x20–0x7E printable characters
// 0x7F delete character
// 0x80–0xFF out of 7 bit ascii range
if (x < 0x20 || x > 0x7e) {
throw new Error(
"Cannot decode character that is out of printable ASCII range: " + x
);
}
return String.fromCharCode(x);
});

return fromNums(Array.from(data)).join("");
}
2 changes: 1 addition & 1 deletion js/src/testvectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { readFileSync } from "fs";

import { compress } from "./compress";
import { ics23 } from "./generated/codecimpl";
import { fromHex } from "./helpers";
import {
batchVerifyMembership,
batchVerifyNonMembership,
verifyMembership,
verifyNonMembership
} from "./ics23";
import { iavlSpec, tendermintSpec } from "./proofs";
import { fromHex } from "./testhelpers.spec";

describe("calculateExistenceRoot", () => {
interface RefData {
Expand Down

0 comments on commit a48c323

Please sign in to comment.