mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
faucet: Update tests for Stargate
This commit is contained in:
parent
445f5f8ccc
commit
a1ddf9dda7
@ -1,6 +1,7 @@
|
|||||||
import { Random } from "@cosmjs/crypto";
|
import { Random } from "@cosmjs/crypto";
|
||||||
import { Bech32 } from "@cosmjs/encoding";
|
import { Bech32 } from "@cosmjs/encoding";
|
||||||
import { CosmosClient } from "@cosmjs/launchpad";
|
import { CosmosClient } from "@cosmjs/launchpad";
|
||||||
|
import { StargateClient } from "@cosmjs/stargate";
|
||||||
import { assert } from "@cosmjs/utils";
|
import { assert } from "@cosmjs/utils";
|
||||||
|
|
||||||
import { Faucet } from "./faucet";
|
import { Faucet } from "./faucet";
|
||||||
@ -12,7 +13,12 @@ function pendingWithoutWasmd(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const httpUrl = "http://localhost:1317";
|
function pendingWithoutSimapp(): void {
|
||||||
|
if (!process.env.SIMAPP_ENABLED) {
|
||||||
|
return pending("Set SIMAPP_ENABLED to enabled Stargate node-based tests");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const defaultTokenConfig: TokenConfiguration = {
|
const defaultTokenConfig: TokenConfiguration = {
|
||||||
bankTokens: ["ucosm", "ustake"],
|
bankTokens: ["ucosm", "ustake"],
|
||||||
};
|
};
|
||||||
@ -26,143 +32,433 @@ const faucetMnemonic =
|
|||||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone";
|
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone";
|
||||||
|
|
||||||
describe("Faucet", () => {
|
describe("Faucet", () => {
|
||||||
describe("constructor", () => {
|
describe("launchpad", () => {
|
||||||
it("can be constructed", async () => {
|
const apiUrl = "http://localhost:1317";
|
||||||
pendingWithoutWasmd();
|
const stargate = false;
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
|
||||||
expect(faucet).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("availableTokens", () => {
|
describe("constructor", () => {
|
||||||
it("is empty when no tokens are configured", async () => {
|
it("can be constructed", async () => {
|
||||||
pendingWithoutWasmd();
|
pendingWithoutWasmd();
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, { bankTokens: [] }, faucetMnemonic, 3);
|
const faucet = await Faucet.make(
|
||||||
const tickers = await faucet.availableTokens();
|
apiUrl,
|
||||||
expect(tickers).toEqual([]);
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
expect(faucet).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is not empty with default token config", async () => {
|
describe("availableTokens", () => {
|
||||||
pendingWithoutWasmd();
|
it("is empty when no tokens are configured", async () => {
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
pendingWithoutWasmd();
|
||||||
const tickers = await faucet.availableTokens();
|
const faucet = await Faucet.make(
|
||||||
expect(tickers).toEqual(["ucosm", "ustake"]);
|
apiUrl,
|
||||||
});
|
defaultAddressPrefix,
|
||||||
});
|
{ bankTokens: [] },
|
||||||
|
faucetMnemonic,
|
||||||
describe("send", () => {
|
3,
|
||||||
it("can send bank token", async () => {
|
stargate,
|
||||||
pendingWithoutWasmd();
|
);
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
const tickers = await faucet.availableTokens();
|
||||||
const recipient = makeRandomAddress();
|
expect(tickers).toEqual([]);
|
||||||
await faucet.send({
|
|
||||||
amount: {
|
|
||||||
amount: "23456",
|
|
||||||
denom: "ucosm",
|
|
||||||
},
|
|
||||||
sender: faucet.holderAddress,
|
|
||||||
recipient: recipient,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const readOnlyClient = new CosmosClient(httpUrl);
|
it("is not empty with default token config", async () => {
|
||||||
const account = await readOnlyClient.getAccount(recipient);
|
pendingWithoutWasmd();
|
||||||
assert(account);
|
const faucet = await Faucet.make(
|
||||||
expect(account.balance).toEqual([
|
apiUrl,
|
||||||
{
|
defaultAddressPrefix,
|
||||||
amount: "23456",
|
defaultTokenConfig,
|
||||||
denom: "ucosm",
|
faucetMnemonic,
|
||||||
},
|
3,
|
||||||
]);
|
stargate,
|
||||||
|
);
|
||||||
|
const tickers = await faucet.availableTokens();
|
||||||
|
expect(tickers).toEqual(["ucosm", "ustake"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("send", () => {
|
||||||
|
it("can send bank token", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.send({
|
||||||
|
amount: {
|
||||||
|
amount: "23456",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
sender: faucet.holderAddress,
|
||||||
|
recipient: recipient,
|
||||||
|
});
|
||||||
|
|
||||||
|
const readOnlyClient = new CosmosClient(apiUrl);
|
||||||
|
const account = await readOnlyClient.getAccount(recipient);
|
||||||
|
assert(account);
|
||||||
|
expect(account.balance).toEqual([
|
||||||
|
{
|
||||||
|
amount: "23456",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("refill", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
await faucet.refill();
|
||||||
|
const readOnlyClient = new CosmosClient(apiUrl);
|
||||||
|
const distributorBalance = (await readOnlyClient.getAccount(faucet.distributorAddresses[0]))?.balance;
|
||||||
|
assert(distributorBalance);
|
||||||
|
expect(distributorBalance).toEqual([
|
||||||
|
jasmine.objectContaining({
|
||||||
|
denom: "ucosm",
|
||||||
|
}),
|
||||||
|
jasmine.objectContaining({
|
||||||
|
denom: "ustake",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(Number.parseInt(distributorBalance[0].amount, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||||
|
expect(Number.parseInt(distributorBalance[1].amount, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("credit", () => {
|
||||||
|
it("works for fee token", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.credit(recipient, "ucosm");
|
||||||
|
|
||||||
|
const readOnlyClient = new CosmosClient(apiUrl);
|
||||||
|
const account = await readOnlyClient.getAccount(recipient);
|
||||||
|
assert(account);
|
||||||
|
expect(account.balance).toEqual([
|
||||||
|
{
|
||||||
|
amount: "10000000",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works for stake token", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.credit(recipient, "ustake");
|
||||||
|
|
||||||
|
const readOnlyClient = new CosmosClient(apiUrl);
|
||||||
|
const account = await readOnlyClient.getAccount(recipient);
|
||||||
|
assert(account);
|
||||||
|
expect(account.balance).toEqual([
|
||||||
|
{
|
||||||
|
amount: "10000000",
|
||||||
|
denom: "ustake",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("configuredTokens", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const tickers = faucet.configuredTokens();
|
||||||
|
expect(tickers).toEqual(["ucosm", "ustake"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("loadAccounts", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutWasmd();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
1,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const accounts = await faucet.loadAccounts();
|
||||||
|
|
||||||
|
const readOnlyClient = new CosmosClient(apiUrl);
|
||||||
|
const expectedHolderAccount = await readOnlyClient.getAccount(faucet.holderAddress);
|
||||||
|
const expectedDistributorAccount = await readOnlyClient.getAccount(faucet.distributorAddresses[0]);
|
||||||
|
assert(expectedHolderAccount);
|
||||||
|
assert(expectedDistributorAccount);
|
||||||
|
expect(accounts).toEqual([
|
||||||
|
jasmine.objectContaining({
|
||||||
|
address: expectedHolderAccount.address,
|
||||||
|
balance: expectedHolderAccount.balance,
|
||||||
|
}),
|
||||||
|
jasmine.objectContaining({
|
||||||
|
address: expectedDistributorAccount.address,
|
||||||
|
balance: expectedDistributorAccount.balance,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("refill", () => {
|
describe("stargate", () => {
|
||||||
it("works", async () => {
|
const apiUrl = "localhost:26657";
|
||||||
pendingWithoutWasmd();
|
const stargate = true;
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
let originalEnvVariable: string | undefined;
|
||||||
await faucet.refill();
|
|
||||||
const readOnlyClient = new CosmosClient(httpUrl);
|
|
||||||
const distributorBalance = (await readOnlyClient.getAccount(faucet.distributorAddresses[0]))?.balance;
|
|
||||||
assert(distributorBalance);
|
|
||||||
expect(distributorBalance).toEqual([
|
|
||||||
jasmine.objectContaining({
|
|
||||||
denom: "ucosm",
|
|
||||||
}),
|
|
||||||
jasmine.objectContaining({
|
|
||||||
denom: "ustake",
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
expect(Number.parseInt(distributorBalance[0].amount, 10)).toBeGreaterThanOrEqual(80_000000);
|
|
||||||
expect(Number.parseInt(distributorBalance[1].amount, 10)).toBeGreaterThanOrEqual(80_000000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("credit", () => {
|
beforeAll(() => {
|
||||||
it("works for fee token", async () => {
|
originalEnvVariable = process.env.FAUCET_CREDIT_AMOUNT_USTAKE;
|
||||||
pendingWithoutWasmd();
|
process.env.FAUCET_CREDIT_AMOUNT_USTAKE = "100000";
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
|
||||||
const recipient = makeRandomAddress();
|
|
||||||
await faucet.credit(recipient, "ucosm");
|
|
||||||
|
|
||||||
const readOnlyClient = new CosmosClient(httpUrl);
|
|
||||||
const account = await readOnlyClient.getAccount(recipient);
|
|
||||||
assert(account);
|
|
||||||
expect(account.balance).toEqual([
|
|
||||||
{
|
|
||||||
amount: "10000000",
|
|
||||||
denom: "ucosm",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works for stake token", async () => {
|
afterAll(() => {
|
||||||
pendingWithoutWasmd();
|
process.env.FAUCET_CREDIT_AMOUNT_USTAKE = originalEnvVariable;
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
|
||||||
const recipient = makeRandomAddress();
|
|
||||||
await faucet.credit(recipient, "ustake");
|
|
||||||
|
|
||||||
const readOnlyClient = new CosmosClient(httpUrl);
|
|
||||||
const account = await readOnlyClient.getAccount(recipient);
|
|
||||||
assert(account);
|
|
||||||
expect(account.balance).toEqual([
|
|
||||||
{
|
|
||||||
amount: "10000000",
|
|
||||||
denom: "ustake",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("configuredTokens", () => {
|
describe("constructor", () => {
|
||||||
it("works", async () => {
|
it("can be constructed", async () => {
|
||||||
pendingWithoutWasmd();
|
pendingWithoutSimapp();
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 3);
|
const faucet = await Faucet.make(
|
||||||
const tickers = faucet.configuredTokens();
|
apiUrl,
|
||||||
expect(tickers).toEqual(["ucosm", "ustake"]);
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
expect(faucet).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("loadAccounts", () => {
|
describe("availableTokens", () => {
|
||||||
it("works", async () => {
|
it("is empty when no tokens are configured", async () => {
|
||||||
pendingWithoutWasmd();
|
pendingWithoutSimapp();
|
||||||
const faucet = await Faucet.make(httpUrl, defaultAddressPrefix, defaultTokenConfig, faucetMnemonic, 1);
|
const faucet = await Faucet.make(
|
||||||
const accounts = await faucet.loadAccounts();
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
{ bankTokens: [] },
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const tickers = await faucet.availableTokens();
|
||||||
|
expect(tickers).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
const readOnlyClient = new CosmosClient(httpUrl);
|
it("is not empty with default token config", async () => {
|
||||||
const expectedHolderAccount = await readOnlyClient.getAccount(faucet.holderAddress);
|
pendingWithoutSimapp();
|
||||||
const expectedDistributorAccount = await readOnlyClient.getAccount(faucet.distributorAddresses[0]);
|
const faucet = await Faucet.make(
|
||||||
assert(expectedHolderAccount);
|
apiUrl,
|
||||||
assert(expectedDistributorAccount);
|
defaultAddressPrefix,
|
||||||
expect(accounts).toEqual([
|
defaultTokenConfig,
|
||||||
jasmine.objectContaining({
|
faucetMnemonic,
|
||||||
address: expectedHolderAccount.address,
|
3,
|
||||||
balance: expectedHolderAccount.balance,
|
stargate,
|
||||||
}),
|
);
|
||||||
jasmine.objectContaining({
|
const tickers = await faucet.availableTokens();
|
||||||
address: expectedDistributorAccount.address,
|
expect(tickers).toEqual(["ucosm", "ustake"]);
|
||||||
balance: expectedDistributorAccount.balance,
|
});
|
||||||
}),
|
});
|
||||||
]);
|
|
||||||
|
describe("send", () => {
|
||||||
|
it("can send bank token", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.send({
|
||||||
|
amount: {
|
||||||
|
amount: "23456",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
sender: faucet.holderAddress,
|
||||||
|
recipient: recipient,
|
||||||
|
});
|
||||||
|
|
||||||
|
const readOnlyClient = await StargateClient.connect(apiUrl);
|
||||||
|
const account = await readOnlyClient.getAllBalancesUnverified(recipient);
|
||||||
|
assert(account);
|
||||||
|
expect(account).toEqual([
|
||||||
|
{
|
||||||
|
amount: "23456",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("refill", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
await faucet.refill();
|
||||||
|
const readOnlyClient = await StargateClient.connect(apiUrl);
|
||||||
|
const distributorBalance = await readOnlyClient.getAllBalancesUnverified(
|
||||||
|
faucet.distributorAddresses[0],
|
||||||
|
);
|
||||||
|
assert(distributorBalance);
|
||||||
|
expect(distributorBalance).toEqual([
|
||||||
|
jasmine.objectContaining({
|
||||||
|
denom: "ucosm",
|
||||||
|
}),
|
||||||
|
jasmine.objectContaining({
|
||||||
|
denom: "ustake",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
expect(Number.parseInt(distributorBalance[0].amount, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||||
|
expect(Number.parseInt(distributorBalance[1].amount, 10)).toBeGreaterThanOrEqual(800000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("credit", () => {
|
||||||
|
it("works for fee token", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.credit(recipient, "ucosm");
|
||||||
|
|
||||||
|
const readOnlyClient = await StargateClient.connect(apiUrl);
|
||||||
|
const balance = await readOnlyClient.getAllBalancesUnverified(recipient);
|
||||||
|
assert(balance);
|
||||||
|
expect(balance).toEqual([
|
||||||
|
{
|
||||||
|
amount: "10000000",
|
||||||
|
denom: "ucosm",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works for stake token", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const recipient = makeRandomAddress();
|
||||||
|
await faucet.credit(recipient, "ustake");
|
||||||
|
|
||||||
|
const readOnlyClient = await StargateClient.connect(apiUrl);
|
||||||
|
const balance = await readOnlyClient.getAllBalancesUnverified(recipient);
|
||||||
|
assert(balance);
|
||||||
|
expect(balance).toEqual([
|
||||||
|
{
|
||||||
|
amount: "100000",
|
||||||
|
denom: "ustake",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("configuredTokens", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
3,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const tickers = faucet.configuredTokens();
|
||||||
|
expect(tickers).toEqual(["ucosm", "ustake"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("loadAccounts", () => {
|
||||||
|
it("works", async () => {
|
||||||
|
pendingWithoutSimapp();
|
||||||
|
const faucet = await Faucet.make(
|
||||||
|
apiUrl,
|
||||||
|
defaultAddressPrefix,
|
||||||
|
defaultTokenConfig,
|
||||||
|
faucetMnemonic,
|
||||||
|
1,
|
||||||
|
stargate,
|
||||||
|
);
|
||||||
|
const accounts = await faucet.loadAccounts();
|
||||||
|
|
||||||
|
const readOnlyClient = await StargateClient.connect(apiUrl);
|
||||||
|
const expectedHolderBalance = await readOnlyClient.getAllBalancesUnverified(faucet.holderAddress);
|
||||||
|
const expectedDistributorBalance = await readOnlyClient.getAllBalancesUnverified(
|
||||||
|
faucet.distributorAddresses[0],
|
||||||
|
);
|
||||||
|
assert(expectedHolderBalance);
|
||||||
|
assert(expectedDistributorBalance);
|
||||||
|
expect(accounts).toEqual([
|
||||||
|
jasmine.objectContaining({
|
||||||
|
address: faucet.holderAddress,
|
||||||
|
balance: expectedHolderBalance,
|
||||||
|
}),
|
||||||
|
jasmine.objectContaining({
|
||||||
|
address: faucet.distributorAddresses[0],
|
||||||
|
balance: expectedDistributorBalance,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user