forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstellar.test.ts
More file actions
23 lines (20 loc) · 1.27 KB
/
Copy pathstellar.test.ts
File metadata and controls
23 lines (20 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
process.env.PUBLIC_STELLAR_NETWORK = "TESTNET";
process.env.PUBLIC_STELLAR_NETWORK_PASSPHRASE = "Test SDF Network ; September 2015";
process.env.PUBLIC_STELLAR_RPC_URL = "https://soroban-testnet.stellar.org";
process.env.PUBLIC_STELLAR_HORIZON_URL = "https://horizon-testnet.stellar.org";
process.env.PUBLIC_PROMPT_HASH_CONTRACT_ID = `C${"A".repeat(55)}`;
process.env.PUBLIC_STELLAR_NATIVE_ASSET_CONTRACT_ID = `C${"B".repeat(55)}`;
import { loadStellarConfig } from "./stellar";
const valid = {
PUBLIC_STELLAR_NETWORK: "TESTNET",
PUBLIC_STELLAR_NETWORK_PASSPHRASE: "Test SDF Network ; September 2015",
PUBLIC_STELLAR_RPC_URL: "https://soroban-testnet.stellar.org",
PUBLIC_STELLAR_HORIZON_URL: "https://horizon-testnet.stellar.org",
PUBLIC_PROMPT_HASH_CONTRACT_ID: `C${"A".repeat(55)}`,
PUBLIC_STELLAR_NATIVE_ASSET_CONTRACT_ID: `C${"B".repeat(55)}`,
};
describe("loadStellarConfig", () => {
it("returns an immutable typed config", () => expect(Object.isFrozen(loadStellarConfig(valid))).toBe(true));
it("fails fast when required values are missing", () => expect(() => loadStellarConfig({})).toThrow(/Invalid Stellar configuration/));
it("rejects malformed contract ids", () => expect(() => loadStellarConfig({ ...valid, PUBLIC_PROMPT_HASH_CONTRACT_ID: "bad" })).toThrow());
});