Skip to content

Commit

Permalink
Refactor voucher tests file (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
zguesmi authored May 23, 2024
2 parents 86a5133 + 295037d commit f37033e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 204 deletions.
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

0 comments on commit f37033e

Please sign in to comment.