-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(test): merged random generation functions into one file (#1570)
- Loading branch information
1 parent
24db1f9
commit 72e0f2c
Showing
8 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.