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

feat: remove test to verify coverage #8

Closed
wants to merge 7 commits into from
Closed
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
20 changes: 8 additions & 12 deletions .github/workflows/coverage-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
ref: development
path: development

- name: Setup Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -30,11 +31,10 @@ jobs:

- name: Get development branch coverage
id: coverage-development
working-directory: development/packages/contracts
run: |
cd ./packages/contracts

# generates lcov.info
forge coverage --report lcov
forge build && forge coverage --report lcov

# Foundry uses relative paths but Hardhat uses absolute paths.
# Convert absolute paths to relative paths for consistency.
Expand All @@ -59,28 +59,25 @@ jobs:
"src/dollar/utils/*" \
"test/*" \


# Generate summary
COVERAGE_DEVELOPMENT_OUTPUT=$(lcov \
--rc lcov_branch_coverage=1 \
--list filtered-lcov.info)

echo COVERAGE=$(echo "${COVERAGE_DEVELOPMENT_OUTPUT}" | tail -n 1 | cut -d % -f 1 | cut -d \| -f 2) >> $GITHUB_OUTPUT

- name: Delete development branch folder
run: rm -rf development

- name: Checkout code in PR branch
uses: actions/checkout@v3

- name: Update Forge Dependencies
working-directory: packages/contracts
run: forge update lib/forge-std

- name: Get PR branch coverage
id: coverage-pr
working-directory: packages/contracts
run: |
cd ./packages/contracts

# generates lcov.info
forge coverage --report lcov
forge build && forge coverage --report lcov

# Foundry uses relative paths but Hardhat uses absolute paths.
# Convert absolute paths to relative paths for consistency.
Expand All @@ -105,7 +102,6 @@ jobs:
"src/dollar/utils/*" \
"test/*" \


# Generate summary
COVERAGE_DEVELOPMENT_OUTPUT=$(lcov \
--rc lcov_branch_coverage=1 \
Expand Down
4 changes: 0 additions & 4 deletions packages/contracts/test/diamond/DiamondTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ contract TestDiamond is DiamondTestSetup {
assertEq(isSupported, true);
}

function testHasMultipleFacets() public {
assertEq(facetAddressList.length, 19);
}

function testFacetsHaveCorrectSelectors() public {
for (uint256 i = 0; i < facetAddressList.length; i++) {
bytes4[] memory fromLoupeFacet = diamondLoupeFacet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,6 @@ contract CollectableDustFacetTest is DiamondTestSetup {
vm.stopPrank();
}

// test sendDust function should revert when token is part of the protocol
function testSendDust_ShouldRevertWhenPartOfTheProtocol() public {
vm.startPrank(admin);
vm.expectEmit(true, true, true, true);
emit ProtocolTokenAdded(address(diamond));
collectableDustFacet.addProtocolToken(address(diamond));
// mint dollar

dollarToken.mint(address(diamond), 100);
vm.stopPrank();
vm.prank(stakingManager);
vm.expectRevert("collectable-dust::token-is-part-of-the-protocol");
collectableDustFacet.sendDust(mock_recipient, address(diamond), 100);
}

// test sendDust function should work only for staking manager
function testSendDust_ShouldWork() public {
assertEq(mockToken.balanceOf(address(diamond)), 100);
vm.prank(stakingManager);
vm.expectEmit(true, true, true, true);
emit DustSent(mock_recipient, address(mockToken), 100);
collectableDustFacet.sendDust(mock_recipient, address(mockToken), 100);
assertEq(mockToken.balanceOf(mock_recipient), 100);
}

// test sendDust function should work when token is no longer part of the protocol
function testSendDust_ShouldWorkWhenNotPartOfTheProtocol() public {
vm.startPrank(admin);
Expand Down
42 changes: 0 additions & 42 deletions packages/contracts/test/dollar/core/UbiquityDollarToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,48 +66,6 @@ contract UbiquityDollarTokenTest is LocalTestHelper {
dollarToken.setIncentiveContract(mock_sender, incentive_addr);
}

function testTransfer_ShouldCallIncentivize_IfValidTransfer() public {
address userA = address(0x100001);
address userB = address(0x100001);
vm.startPrank(admin);
dollarToken.mint(userA, 100);
dollarToken.mint(userB, 100);
dollarToken.mint(mock_sender, 100);

dollarToken.setIncentiveContract(mock_sender, incentive_addr);
dollarToken.setIncentiveContract(mock_recipient, incentive_addr);
dollarToken.setIncentiveContract(mock_operator, incentive_addr);
dollarToken.setIncentiveContract(address(0), incentive_addr);
dollarToken.setIncentiveContract(dollar_addr, incentive_addr);
vm.stopPrank();

vm.prank(mock_sender);
vm.expectCall(
incentive_addr,
abi.encodeWithSelector(
Incentive.incentivize.selector,
mock_sender,
userB,
mock_sender,
1
)
);
dollarToken.transfer(userB, 1);

vm.prank(userA);
vm.expectCall(
incentive_addr,
abi.encodeWithSelector(
Incentive.incentivize.selector,
userA,
mock_recipient,
userA,
1
)
);
dollarToken.transfer(mock_recipient, 1);
}

function testUUPS_ShouldUpgradeAndCall() external {
UbiquityDollarTokenUpgraded newImpl = new UbiquityDollarTokenUpgraded();

Expand Down
Loading