Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Use Allowlist enum in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Oct 4, 2023
1 parent c1ff29f commit 20dfb7b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
11 changes: 9 additions & 2 deletions test/core/accounts/AccountsAllowance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "typechain-types";
import {genWallet, getProxyAdminOwner, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";
import {AllowlistType} from "types";

describe("AccountsAllowance", function () {
const {ethers} = hre;
Expand Down Expand Up @@ -66,8 +67,14 @@ describe("AccountsAllowance", function () {
);

// Beneficiaries & Maturity Allowlists set for endowment user
await wait(state.setAllowlist(ACCOUNT_ID, 0, [await user.getAddress()])); // beneficiaries
await wait(state.setAllowlist(ACCOUNT_ID, 2, [await user.getAddress()])); // maturity
await wait(
state.setAllowlist(ACCOUNT_ID, AllowlistType.AllowlistedBeneficiaries, [
await user.getAddress(),
])
);
await wait(
state.setAllowlist(ACCOUNT_ID, AllowlistType.MaturityAllowlist, [await user.getAddress()])
);
});

let snapshot: SnapshotRestorer;
Expand Down
32 changes: 24 additions & 8 deletions test/core/accounts/AccountsDepositWithdrawEndowments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,14 @@ describe("AccountsDepositWithdrawEndowments", function () {
// setup an allowed contributor wallet to sign/send
const allowedContributor = await genWallet().address;
await impersonateAccount(allowedContributor);
await setBalance(allowedContributor, 1000000000000000000); // give it some gas money, as impersonateAccount does not
await setBalance(allowedContributor, 1000000000000000000n); // give it some gas money, as impersonateAccount does not
const acctSigner = await ethers.getSigner(allowedContributor);
// set a different wallet in allowlist
await wait(state.setAllowlist(normalEndowId, 1, [genWallet().address]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedContributors, [
genWallet().address,
])
);

await expect(
facet
Expand All @@ -528,10 +532,14 @@ describe("AccountsDepositWithdrawEndowments", function () {
// setup an allowed contributor wallet to sign/send and setup in allowlist
const allowedContributor = await genWallet().address;
await impersonateAccount(allowedContributor);
await setBalance(allowedContributor, 1000000000000000000); // give it some gas money, as impersonateAccount does not
await setBalance(allowedContributor, 1000000000000000000n); // give it some gas money, as impersonateAccount does not
const acctSigner = await ethers.getSigner(allowedContributor);
// set new signer's wallet in allowlist
await wait(state.setAllowlist(normalEndowId, 1, [allowedContributor]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedContributors, [
allowedContributor,
])
);

const expectedLockedAmt = BigNumber.from(4000);
const expectedLiquidAmt = BigNumber.from(6000);
Expand Down Expand Up @@ -779,7 +787,11 @@ describe("AccountsDepositWithdrawEndowments", function () {
});

it("reverts if beneficiary address is not listed in allowlistedBeneficiaries nor is it the Endowment Owner", async () => {
await wait(state.setAllowlist(normalEndowId, 0, [genWallet().address]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedBeneficiaries, [
genWallet().address,
])
);

await expect(
facet.withdraw(normalEndowId, VaultType.LIQUID, genWallet().address, 0, [
Expand Down Expand Up @@ -814,7 +826,7 @@ describe("AccountsDepositWithdrawEndowments", function () {
it("reverts for a closed endowment (endow beneficiary) when a wallet that is not the beneficiary endowment owner tries to withdraw", async () => {
const beneficiaryAddress = genWallet().address;
await impersonateAccount(beneficiaryAddress);
await setBalance(beneficiaryAddress, 1000000000000000000); // give it some gas money, as impersonateAccount does not
await setBalance(beneficiaryAddress, 1000000000000000000n); // give it some gas money, as impersonateAccount does not
const acctSigner = await ethers.getSigner(beneficiaryAddress);

// setup new charity-type endow
Expand Down Expand Up @@ -844,7 +856,7 @@ describe("AccountsDepositWithdrawEndowments", function () {
it("passes: closed endowment with beneficiary address set, sender is beneficiary wallet, no fees applied ", async () => {
const beneficiaryAddress = genWallet().address;
await impersonateAccount(beneficiaryAddress);
await setBalance(beneficiaryAddress, 1000000000000000000); // give it some gas money, as impersonateAccount does not
await setBalance(beneficiaryAddress, 1000000000000000000n); // give it some gas money, as impersonateAccount does not
const acctSigner = await ethers.getSigner(beneficiaryAddress);
const beneficiaryId = 0;
const acctType = VaultType.LIQUID;
Expand Down Expand Up @@ -1154,7 +1166,11 @@ describe("AccountsDepositWithdrawEndowments", function () {
withdrawFee: {payoutAddress: await endowOwner.getAddress(), bps: 10}, // 0.1%
};
await wait(state.setEndowmentDetails(normalEndowId, normalWithAllowlist));
await wait(state.setAllowlist(normalEndowId, 0, [beneficiaryAddress]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedBeneficiaries, [
beneficiaryAddress,
])
);

await expect(
facet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {genWallet, getProxyAdminOwner, getSigners} from "utils";
import {deployFacetAsProxy, updateAllSettings} from "./utils";
import {AllowlistType} from "types";

use(smock.matchers);

Expand Down Expand Up @@ -227,7 +228,9 @@ describe("AccountsUpdateEndowmentSettingsController", function () {
it("returns same members in starting allowlist if only pre-existing addresses are passed in add", async () => {
// set starting allowlist
const wallet = await genWallet().address;
await wait(state.setAllowlist(normalEndowId, 0, [wallet]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedBeneficiaries, [wallet])
);

const remove: any[] = [];
const add: any[] = [wallet];
Expand All @@ -245,7 +248,9 @@ describe("AccountsUpdateEndowmentSettingsController", function () {
const wallet3 = await genWallet().address;

// set starting allowlist
await wait(state.setAllowlist(normalEndowId, 0, [wallet]));
await wait(
state.setAllowlist(normalEndowId, AllowlistType.AllowlistedBeneficiaries, [wallet])
);

const remove: any[] = [wallet2];
const add: any[] = [wallet, wallet2, wallet3];
Expand Down

0 comments on commit 20dfb7b

Please sign in to comment.