Skip to content
Open
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
4 changes: 4 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use flake
export VIRTUAL_ENV="tests/integration_tests/.venv"
layout python
TMPDIR=/tmp
100 changes: 100 additions & 0 deletions .github/workflows/tests-e2e-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: E2E Nix Tests
on:
push:
branches: [ main, release/** ]
pull_request:
branches: [ main, release/** ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-env:
runs-on: ubuntu-latest
outputs:
run_tests: ${{ steps.set-run-tests.outputs.run_tests }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Skip marker (commit message)
run: |
msg="$(git log -1 --pretty=%B)"
if echo "$msg" | grep -qi '\[skip e2e\]'; then
echo "Skipping E2E by marker."
echo "run_tests=false" >> "$GITHUB_OUTPUT"
exit 0
fi
- id: changed-files
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c
with:
files: |
docs/**
**/*.md
- id: set-run-tests
run: |
if [ "${{ steps.changed-files.outputs.only_changed }}" = "true" ]; then
echo "Docs-only change detected. Skipping tests."
echo "run_tests=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "run_tests=true" >> "$GITHUB_OUTPUT"
- name: Free disk space
if: steps.set-run-tests.outputs.run_tests == 'true'
run: sudo rm -rf /usr/share/dotnet /opt/ghc "/usr/local/share/boost" "$AGENT_TOOLSDIRECTORY" || true
- name: Install Nix
if: steps.set-run-tests.outputs.run_tests == 'true'
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b
with:
nix_path: nixpkgs=channel:nixos-25.05
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
sandbox = false
- name: Enable Magic Nix Cache
if: steps.set-run-tests.outputs.run_tests == 'true'
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Pre-build dependencies (warm cache)
if: steps.set-run-tests.outputs.run_tests == 'true'
run: |
nix build .#evmd .#hermes || true
integration_tests:
needs: build-env
if: needs.build-env.outputs.run_tests == 'true'
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: true
matrix:
group: [all]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b
with:
nix_path: nixpkgs=channel:nixos-25.05
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
sandbox = false
- name: Enable Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run test group via Makefile
env:
TESTS_TO_RUN: ${{ matrix.group }}
run: make test-e2e-nix TESTS_TO_RUN="${TESTS_TO_RUN}"
- name: Collect debug artifacts
if: failure()
run: tar cfz debug_${{ matrix.group }}.tar.gz -C "${TMPDIR-/tmp}/pytest-of-runner" . || true
- name: Upload debug artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: debug-${{ matrix.group }}
path: debug_${{ matrix.group }}.tar.gz
if-no-files-found: ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ build/
tests/systemtests/binaries
tests/systemtests/testnet
.testnets

# Environments
*.env
/.envrc
.venv
/.direnv
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
[submodule "tests/evm-tools-compatibility/foundry/lib/forge-std"]
path = tests/evm-tools-compatibility/foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "tests/integration_tests/contracts/openzeppelin-contracts-upgradeable"]
path = tests/integration_tests/contracts/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable.git
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ test-solidity:
@echo "Beginning solidity tests..."
./scripts/run-solidity-tests.sh

test-e2e-nix:
@bash ./tests/scripts/restore_envs.sh
@nix develop --command bash -c "cd tests/integration_tests && uv sync && CHAIN_CONFIG=$(CHAIN_CONFIG) ../../tests/scripts/run-integration-tests.sh"

.PHONY: run-tests test test-all $(TEST_TARGETS)

benchmark:
Expand Down
46 changes: 46 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
lib,
stdenv,
buildGo125Module,
rev ? "dirty",
}:
buildGo125Module rec {
version = "v0.5.0";
pname = "evmd";
tags = [
"ledger"
"ledger_zemu"
"netgo" # pure go dns resolver
"osusergo" # pure go user/group lookup
"pebbledb"
];
ldflags = [
"-X github.com/cosmos/cosmos-sdk/version.Name=evmd"
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
"-X github.com/cosmos/cosmos-sdk/version.Version=${version}"
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${lib.concatStringsSep "," tags}"
"-X github.com/cosmos/cosmos-sdk/version.Commit=${rev}"
];

src = lib.sourceByRegex ./. [
"^(evmd|ante|api|client|crypto|encoding|ethereum|ibc|indexer|mempool|metrics|precompiles|proto|rpc|server|testutil|utils|version|wallets|x|eips|contracts|go.mod|go.sum|interfaces.go)($|/.*)"
"^tests(/.*[.]go)?$"
];
vendorHash = "sha256-+L4nKIKHV1bos9Trr50/kG69hR8iNL6MXLi9mun5iXQ=";
proxyVendor = true;
env = {
CGO_ENABLED = "1";
};

sourceRoot = "source/evmd";
subPackages = [ "cmd/evmd" ];

doCheck = false;
meta = with lib; {
description = "An EVM compatible framework for blockchain development with the Cosmos SDK";
homepage = "https://github.com/cosmos/evm";
license = licenses.asl20;
mainProgram = "evmd" + stdenv.hostPlatform.extensions.executable;
platforms = platforms.all;
};
}
79 changes: 79 additions & 0 deletions flake.lock

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

59 changes: 59 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-25.05";
flake-utils.url = "github:numtide/flake-utils";
hermes = {
url = "github:mmsqe/ibc-rs/ae80ab348952840696e6c9a0c7096d2de11ea579";
flake = false;
};
};

outputs =
{
self,
nixpkgs,
flake-utils,
hermes,
}:
let
rev = self.shortRev or "dirty";
in
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays.default;
config = { };
};
in
{
legacyPackages = pkgs;
packages.default = pkgs.evmd;
devShells = {
default = pkgs.mkShell {
buildInputs = [
pkgs.evmd
pkgs.nixfmt-rfc-style
pkgs.solc
pkgs.python312
pkgs.direnv
pkgs.uv
pkgs.git
pkgs.hermes
(pkgs.lib.optional pkgs.stdenv.isLinux pkgs.stdenv.cc.cc)
pkgs.python312Packages.jsonnet
];
};
};
}
))
// {
overlays.default = [
(final: super: {
evmd = final.callPackage ./. { inherit rev; };
hermes = final.callPackage ./tests/nix/hermes.nix { src = hermes; };
})
];
};
}
18 changes: 18 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/make -f

TESTS_TO_RUN ?= all

NIX_DEV_CMD = nix develop --accept-flake-config -c

test-e2e-nix:
@echo "TESTS_TO_RUN=$(TESTS_TO_RUN)"
@bash scripts/restore_envs.sh
@CHAIN_CONFIG=$(CHAIN_CONFIG) TESTS_TO_RUN=$(TESTS_TO_RUN) bash scripts/run-integration-tests.sh

dev:
@$(NIX_DEV_CMD) bash

lint-py:
@cd integration_tests && uv run flake8 --show-source --count --statistics --format="::error file=%(path)s,line=%(row)d,col=%(col)d::%(path)s:%(row)d:%(col)d: %(code)s %(text)s"

.PHONY: test-e2e-nix dev lint-py
4 changes: 4 additions & 0 deletions tests/integration_tests/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E203
exclude = .git,__pycache__,./contracts,./.venv,contracts,.venv
Empty file.
15 changes: 15 additions & 0 deletions tests/integration_tests/configs/accounts.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local config = import 'default.jsonnet';
local chain = (import 'chains.jsonnet')[std.extVar('CHAIN_CONFIG')];

config {
'evm-canary-net-1'+: {
accounts: super.accounts[:std.length(super.accounts) - 1] + [
{
'coin-type': 60,
name: 'user' + i,
coins: '100000000000000000' + chain.evm_denom,
}
for i in std.range(0, 5)
],
},
}
34 changes: 34 additions & 0 deletions tests/integration_tests/configs/chains.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
evmd: {
'account-prefix': 'cosmos',
evm_denom: 'atest',
cmd: 'evmd',
evm_chain_id: 262144,
bank: {
denom_metadata: [{
description: 'Native 18-decimal denom metadata for Cosmos EVM chain',
denom_units: [
{
denom: 'atest',
exponent: 0,
},
{
denom: 'test',
exponent: 18,
},
],
base: 'atest',
display: 'test',
name: 'Cosmos EVM',
symbol: 'ATOM',
}],
},
evm: {},
feemarket: {
params: {
base_fee: '1000000000',
min_gas_price: '1000000000',
},
},
},
}
Loading
Loading