|
| 1 | +import { makeCosmoshubPath } from "@cosmjs/stargate"; |
| 2 | +import { sleep } from "@cosmjs/utils"; |
| 3 | + |
| 4 | +import { Faucet } from "../faucet"; |
| 5 | +import { TokenConfiguration } from "../tokenmanager"; |
| 6 | +import { ChainConstants, Webserver } from "./webserver"; |
| 7 | + |
| 8 | +function pendingWithoutSimapp(): void { |
| 9 | + if (!process.env.SIMAPP47_ENABLED && !process.env.SIMAPP50_ENABLED) { |
| 10 | + return pending("Set SIMAPP{47,50}_ENABLED to enabled Stargate node-based tests"); |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +const defaultTokenConfig: TokenConfiguration = { |
| 15 | + bankTokens: ["ucosm", "ustake"], |
| 16 | +}; |
| 17 | +const defaultAddressPrefix = "cosmos"; |
| 18 | + |
| 19 | +const faucetMnemonic = |
| 20 | + "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone"; |
| 21 | + |
| 22 | +const testingPort = 62222; |
| 23 | + |
| 24 | +describe("Webserver", () => { |
| 25 | + const pathBuilder = makeCosmoshubPath; |
| 26 | + |
| 27 | + const rpcUrl = "http://localhost:26658"; |
| 28 | + let originalEnvVariable: string | undefined; |
| 29 | + |
| 30 | + beforeAll(() => { |
| 31 | + originalEnvVariable = process.env.FAUCET_CREDIT_AMOUNT_USTAKE; |
| 32 | + process.env.FAUCET_CREDIT_AMOUNT_USTAKE = "100000"; |
| 33 | + }); |
| 34 | + |
| 35 | + afterAll(() => { |
| 36 | + process.env.FAUCET_CREDIT_AMOUNT_USTAKE = originalEnvVariable; |
| 37 | + }); |
| 38 | + |
| 39 | + it("can be constructed", async () => { |
| 40 | + pendingWithoutSimapp(); |
| 41 | + const faucet = await Faucet.make( |
| 42 | + rpcUrl, |
| 43 | + defaultAddressPrefix, |
| 44 | + defaultTokenConfig, |
| 45 | + faucetMnemonic, |
| 46 | + pathBuilder, |
| 47 | + 3, |
| 48 | + true, |
| 49 | + ); |
| 50 | + expect(faucet).toBeTruthy(); |
| 51 | + |
| 52 | + const constants: ChainConstants = { |
| 53 | + nodeUrl: rpcUrl, |
| 54 | + chainId: "no idea bro", |
| 55 | + }; |
| 56 | + |
| 57 | + const server = new Webserver(faucet, constants); |
| 58 | + expect(server).toBeTruthy(); |
| 59 | + server.start(testingPort); |
| 60 | + await sleep(2_000); |
| 61 | + }); |
| 62 | +}); |
0 commit comments