Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merged random generation functions for tests into one file #1570

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { storeTransfer, Transfer, Wallet } from "./output/wallet_Wallet";
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox";
import { beginCell, toNano } from "@ton/core";
import { sign } from "@ton/crypto";
import { testKey } from "../src/test/utils/testKey";
import { randomKey } from "../src/test/utils/random-utils";
import "@ton/test-utils";

describe("wallet", () => {
Expand All @@ -16,7 +16,7 @@ describe("wallet", () => {
blockchain.verbosity.print = false;
treasure = await blockchain.treasury("treasure");

key = testKey("wallet-key");
key = randomKey("wallet-key");
const publicKey = beginCell()
.storeBuffer(key.publicKey)
.endCell()
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e-emulated/map1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { randomAddress } from "../utils/randomAddress";
import { randomAddress } from "../utils/random-utils";
import {
MapTestContract,
MapTestContract$Data,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e-emulated/map2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { randomAddress } from "../utils/randomAddress";
import { randomAddress } from "../utils/randomUtils";

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test (22, ubuntu-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test (22, windows-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / backwards-compat (18, ubuntu-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test (22, macos-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / backwards-compat (18, windows-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / backwards-compat (18, macos-latest)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, ubuntu-latest, npm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, ubuntu-latest, yarn)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, ubuntu-latest, pnpm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, ubuntu-latest, bun)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, windows-latest, npm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, windows-latest, yarn)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, windows-latest, pnpm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, windows-latest, bun)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, macos-latest, npm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, macos-latest, yarn)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, macos-latest, pnpm)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.

Check failure on line 3 in src/test/e2e-emulated/map2.spec.ts

View workflow job for this annotation

GitHub Actions / test-blueprint (22, macos-latest, bun)

Cannot find module '../utils/randomUtils' or its corresponding type declarations.
anton-trunov marked this conversation as resolved.
Show resolved Hide resolved
import {
MapTestContract,
MapTestContract$Data,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e-emulated/math.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beginCell, Dictionary, toNano } from "@ton/core";
import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox";
import { MathTester } from "./contracts/output/math_MathTester";
import "@ton/test-utils";
import { randomAddress } from "../utils/randomAddress";
import { randomAddress } from "../utils/random-utils";

describe("math", () => {
let blockchain: Blockchain;
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e-emulated/optionals.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { randomAddress } from "../utils/randomAddress";
import { randomAddress } from "../utils/random-utils";
import {
ContractWithOptionals,
SomeGenericStruct,
Expand Down
21 changes: 21 additions & 0 deletions src/test/utils/random-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Prando from "prando";
import { KeyPair, keyPairFromSeed } from "@ton/crypto";
import { Address } from "@ton/core";

export function randomKey(seed: string): KeyPair {
const random = new Prando(seed);
const res = Buffer.alloc(32);
for (let i = 0; i < res.length; i++) {
res[i] = random.nextInt(0, 256);
}
return keyPairFromSeed(res);
}

export function randomAddress(workchain: number, seed: string): Address {
const random = new Prando(seed);
const hash = Buffer.alloc(32);
for (let i = 0; i < hash.length; i++) {
hash[i] = random.nextInt(0, 255);
}
return new Address(workchain, hash);
}
11 changes: 0 additions & 11 deletions src/test/utils/randomAddress.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/utils/testKey.ts

This file was deleted.

Loading