Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more tests with incorrect await / expect ordering #146

Merged
merged 5 commits into from
Dec 9, 2022
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
2 changes: 1 addition & 1 deletion test/Loan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ describe("Loan", () => {
await collateralizeLoan(loan, borrower, liquidityAsset);
await fundLoan(loan, poolController, poolAdmin);
await time.increaseTo(await loan.dropDeadTimestamp());
expect(await loan.connect(borrower).cancelFunded());
await loan.connect(borrower).cancelFunded();

expect(await loan.state()).to.equal(2);
});
Expand Down
8 changes: 4 additions & 4 deletions test/Pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,17 +713,17 @@ describe("Pool", () => {
expect(await pool.balanceOf(otherAccount.address)).to.equal(97);
});

it("emits a RedeemRequested event if the lender requests a valid amount", async () => {
it("emits a WithdrawRequested event if the lender requests to redeem a valid amount", async () => {
const { pool, poolAdmin, liquidityAsset, otherAccount } =
await loadFixture(loadPoolFixture);
await activatePool(pool, poolAdmin, liquidityAsset);

await depositToPool(pool, otherAccount, liquidityAsset, 100);
const max = await pool.maxRedeemRequest(otherAccount.address);

expect(await pool.connect(otherAccount).requestRedeem(max))
.to.emit(pool.address, "RedeemRequested")
.withArgs(otherAccount.address, max);
await expect(pool.connect(otherAccount).requestRedeem(max))
.to.emit(pool, "WithdrawRequested")
.withArgs(otherAccount.address, max, max);
});
});

Expand Down
15 changes: 7 additions & 8 deletions test/permissioned/PoolAdminAccessControl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,14 @@ describe("PoolAdminAccessControl", () => {
.connect(otherAccount)
.acceptTermsOfService();

expect(
await performVeriteVerification(
poolAdminAccessControl,
operator,
otherAccount
)
)
const txn = await performVeriteVerification(
poolAdminAccessControl,
operator,
otherAccount
);
await expect(txn)
.to.emit(poolAdminAccessControl, "VerificationResultConfirmed")
.withArgs(otherAccount.address, true);
.withArgs(otherAccount.address);
});
});
});
Expand Down
15 changes: 7 additions & 8 deletions test/scenarios/pool/withdraw-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ describe("Withdraw Requests", () => {
expect(await pool.maxWithdrawRequest(bobLender.address)).to.equal(63);

// Request a withdraw from Alice for Period n + 1 (in this case, 1)
expect(await pool.connect(aliceLender).requestWithdraw(50))
.to.emit(pool.address, "WithdrawRequested")
.withArgs(aliceLender.address, 50);
await expect(pool.connect(aliceLender).requestWithdraw(50))
.to.emit(pool, "WithdrawRequested")
.withArgs(aliceLender.address, 50, 50);

// Request a Redeem from Bob for Period n + 1 (in this case, 1)
expect(await pool.connect(bobLender).requestRedeem(10))
.to.emit(pool.address, "RedeemRequested")
.withArgs(bobLender.address, 10);
await expect(pool.connect(bobLender).requestRedeem(10))
.to.emit(pool, "WithdrawRequested")
.withArgs(bobLender.address, 10, 10);

// Ensure a fee was paid (10% of 60 = 6 tokens)
expect(await pool.totalSupply()).to.equal(164);
Expand Down Expand Up @@ -157,7 +156,7 @@ describe("Withdraw Requests", () => {

// Cancel Bob's request
const bobBalance = await pool.balanceOf(bobLender.address);
expect(await pool.connect(bobLender).cancelRedeemRequest(3));
await pool.connect(bobLender).cancelRedeemRequest(3);

// Expect a fee to be paid
expect(await pool.balanceOf(bobLender.address)).to.equal(bobBalance.sub(1));
Expand Down
6 changes: 5 additions & 1 deletion test/support/verite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ export async function performVeriteVerification(
await contract.connect(admin).addCredentialSchema(verificationResult.schema);

// Verify the verification result
await expect(contract.connect(subject).verify(verificationResult, signature))
const txn = await contract
.connect(subject)
.verify(verificationResult, signature);
await expect(txn)
.to.emit(contract, "VerificationResultConfirmed")
.withArgs(subject.address);
return txn;
}