Skip to content

Commit

Permalink
evm: include forge coverage report (#393)
Browse files Browse the repository at this point in the history
fixes #334
  • Loading branch information
hussein-aitlahcen authored Jul 28, 2023
2 parents 389ba65 + ee60ff3 commit db24760
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.8.18;

import "../Base.sol";
import "../../core/25-handler/IBCHandler.sol";
import "../../Base.sol";
import "../../../core/25-handler/IBCHandler.sol";

contract PingPong is IBCAppBase {
IBCHandler private ibcHandler;
Expand Down
54 changes: 34 additions & 20 deletions evm/evm.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }: {
perSystem = { self', inputs', pkgs, proto, forge, nix-filter, ... }:
perSystem = { self', inputs', pkgs, proto, nix-filter, ... }:
let
solidity-stringutils = pkgs.fetchFromGitHub {
owner = "Arachnid";
Expand Down Expand Up @@ -84,7 +84,7 @@
};
wrappedForge = pkgs.symlinkJoin {
name = "forge";
paths = [ forge ];
paths = [ pkgs.foundry-bin ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/forge \
Expand All @@ -94,23 +94,6 @@
${pkgs.lib.foldlAttrs (acc: name: value: "${acc} --set-default ${name} '${value}'") "" foundryEnv}
'';
};
mkEvmContracts = pkgs.stdenv.mkDerivation {
name = "evm-contracts";
src = evmSources;
buildInputs = [ wrappedForge ];
buildPhase = ''
forge build --revert-strings debug
'';
doCheck = true;
checkPhase = ''
forge test --revert-strings debug -vvv --gas-report
'';
installPhase = ''
mkdir -p $out
mv out $out
mv cache $out
'';
};

do-deploy = { where, rpc-url, private-key }:
let
Expand Down Expand Up @@ -217,7 +200,38 @@
'';
};

evm-contracts = mkEvmContracts;
evm-contracts = pkgs.stdenv.mkDerivation {
name = "evm-contracts";
src = evmSources;
buildInputs = [ wrappedForge ];
buildPhase = ''
forge build --revert-strings debug
'';
doCheck = true;
checkPhase = ''
forge --version
forge test --revert-strings debug -vvv --gas-report
'';
installPhase = ''
mkdir -p $out
mv out $out
mv cache $out
'';
};

evm-coverage =
pkgs.runCommand "evm-coverage.log"
{
buildInputs = [ wrappedForge pkgs.lcov ];
} "forge coverage --ir-minimum --report lcov && genhtml lcov.info -o $out --branch-coverage";

show-evm-coverage = pkgs.writeShellApplication {
name = "show-evm-coverage";
runtimeInputs = [ wrappedForge ];
text = ''
xdg-open ${self'.packages.evm-coverage}/index.html
'';
};
} //
builtins.listToAttrs (
builtins.map
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
inputs.nixpkgs.follows = "nixpkgs";
};
foundry = {
url = "github:shazow/foundry.nix/monthly";
# Move back to monthly branch after 08 2023 as they fixed a coverage issue between 07-08
url = "github:shazow/foundry.nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
Expand Down Expand Up @@ -103,6 +104,7 @@
overlays = with inputs; [
rust-overlay.overlays.default
iohk-nix.overlays.crypto
foundry.overlay
];
};

Expand All @@ -126,8 +128,6 @@
};
};

forge = foundry.defaultPackage.${system};

nix-filter = nix-filter.lib;

proto = {
Expand Down Expand Up @@ -264,8 +264,8 @@
});
evm = pkgs.mkShell (baseShell // {
buildInputs = baseShell.buildInputs ++ [
foundry.defaultPackage.${system}
pkgs.solc
pkgs.foundry-bin
pkgs.go-ethereum
];
});
Expand Down

0 comments on commit db24760

Please sign in to comment.