Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions test/governance/GoodDaoHouses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("GoodDaoHouses", () => {
const [admin, committee, citizenOne, citizenTwo, alignmentOne, alignmentTwo, lateCitizen, stranger] =
await ethers.getSigners();

const { gd, nameService, addWhitelisted } = await loadFixture(createDAO);
const { gd, nameService, addWhitelisted, identityDeployed } = await loadFixture(createDAO);

const goodDollar = await ethers.getContractAt("IGoodDollar", gd);
const flowSplitter = await ethers.deployContract("MockFlowSplitter");
Expand All @@ -41,7 +41,8 @@ describe("GoodDaoHouses", () => {
goodDollar,
flowSplitter,
houses,
addWhitelisted
addWhitelisted,
identityDeployed
};
};

Expand Down Expand Up @@ -514,7 +515,8 @@ describe("GoodDaoHouses", () => {
goodDollar,
flowSplitter,
houses,
addWhitelisted
addWhitelisted,
identityDeployed
} = await loadFixture(fixture);

await addWhitelisted(citizenOne.address, "did:gooddollar:citizen-unstake-vote");
Expand All @@ -541,6 +543,8 @@ describe("GoodDaoHouses", () => {

expect(await houses.getFinalizedUnits(voteId, alignmentOne.address)).to.equal(0);

await identityDeployed.authenticate(citizenOne.address);

await expect(
houses.connect(citizenOne).castVote([alignmentOne.address, alignmentTwo.address], [7000, 3000])
).to.be.revertedWith("Invalid recipient");
Expand Down
37 changes: 30 additions & 7 deletions test/reserve/GenericDistributionHelper.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,25 +252,48 @@ describe("GenericDistributionHelper - XDC XSWAP E2E Test", function () {
goodDollar: ethers.utils.formatEther(goodDollarBalanceBefore)
});

// Call onDistribution to trigger swap
await distHelper.onDistribution(0);
const tx = await distHelper.onDistribution(0);
const receipt = await tx.wait();

// Check balances after swap
const xdcBalanceAfter = await ethers.provider.getBalance(distHelper.address);
const goodDollarBalanceAfter = await goodDollar.balanceOf(distHelper.address);
const wxdcBalanceAfter = await gasToken.balanceOf(distHelper.address);
console.log("Balances after swap:", {
xdc: ethers.utils.formatEther(xdcBalanceAfter),
goodDollar: ethers.utils.formatEther(goodDollarBalanceAfter)
});

// Verify swap occurred
const xdcIncrease = xdcBalanceAfter.sub(xdcBalanceBefore);
const wxdcBalanceAfter = await gasToken.balanceOf(distHelper.address);
const wxdcIncrease = wxdcBalanceAfter.sub(wxdcBalanceBefore);
const gdSpent = goodDollarBalanceBefore.sub(goodDollarBalanceAfter);

const buyNativeFailedEvents =
receipt.events?.filter(
(e: any) => e.address === distHelper.address && e.event === "BuyNativeFailed"
) || [];
const distributionEvents =
receipt.events?.filter(
(e: any) => e.address === distHelper.address && e.event === "Distribution"
) || [];

expect(distributionEvents.length, "Distribution event should be emitted").to.be.gt(0);

const nativeBoughtForGas = distributionEvents[0].args?.nativeBoughtForGas ?? BN.from(0);

if (buyNativeFailedEvents.length > 0) {
console.log(
"BuyNativeFailed events:",
buyNativeFailedEvents.map((e: any) => ({
reason: e.args?.reason,
amountToSell: e.args?.amountToSell?.toString?.(),
amountOutMinimum: e.args?.amountOutMinimum?.toString?.()
}))
);
}

expect(
xdcIncrease.gt(0) || wxdcIncrease.gt(0),
"Swap should have increased either WXDC or xdc balance"
nativeBoughtForGas.gt(0) || gdSpent.gt(0) || xdcIncrease.gt(0) || wxdcIncrease.gt(0),
"Distribution should spend G$ or increase fee balances"
).to.be.true;
});

Expand Down
2 changes: 1 addition & 1 deletion test/staking/DonationsStaking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
let stakeAmount = ethers.utils.parseEther("10");
await dai["mint(address,uint256)"](donationsStaking.address, stakeAmount);

expect(donationsStaking.stakeDonations()).to.not.be.reverted;
await expect(donationsStaking.stakeDonations()).to.not.be.reverted;

let encodedData = donationsStaking.interface.encodeFunctionData(
"setActive",
Expand Down
Loading