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

Refactor voucher tests file #18

Merged
merged 10 commits into from
May 23, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## vNEXT
- Refactor voucher tests file. (#18)
- Use real poco address if available at deployment. (#17)
- Match orders boost through voucher. (#16)
- Use hardhat deploy. (#15)
Expand Down
15 changes: 4 additions & 11 deletions scripts/common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ContractTransactionReceipt } from 'ethers';
import { ethers } from 'hardhat';
import { Voucher, VoucherProxy } from '../../typechain-types';
import { VoucherV2Mock } from '../../typechain-types/contracts/mocks';

import { Voucher, VoucherProxy, VoucherV2Mock } from '../typechain-types';

export async function getVoucher(voucherAddress: string): Promise<Voucher> {
return await ethers.getContractAt('Voucher', voucherAddress);
Expand All @@ -20,14 +18,9 @@ export async function getExpectedExpiration(
voucherDuration: number,
txReceipt: ContractTransactionReceipt | null,
): Promise<number> {
if (txReceipt != null) {
const block = await ethers.provider.getBlock(txReceipt.blockNumber);
if (block) {
return block.timestamp + voucherDuration;
} else {
return 0;
}
} else {
if (!txReceipt) {
return 0;
}
const block = await ethers.provider.getBlock(txReceipt.blockNumber);
return block ? block.timestamp + voucherDuration : 0;
}
Loading