Skip to content

Commit

Permalink
fix: incl rustup in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Feb 21, 2024
1 parent 68f5955 commit 5635ddf
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ endif
##################
.PHONY: deps libbacktrace

rustup:
ifeq (, $(shell which cargo))
# Install Rustup if it's not installed
# -y: Assume "yes" for all prompts
# --default-toolchain stable: Install the stable toolchain
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
endif

anvil: rustup
ifeq (, $(shell which anvil))
# Install Anvil if it's not installed
./scripts/install_anvil.sh
endif

deps: | deps-common nat-libs waku.nims


Expand Down Expand Up @@ -166,7 +180,8 @@ testcommon: | build deps
##########
.PHONY: testwaku wakunode2 testwakunode2 example2 chat2 chat2bridge

testwaku: | build deps librln
# install anvil only for the testwaku target
testwaku: | build deps anvil librln
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim test -d:os=$(shell uname) $(NIM_PARAMS) waku.nims

Expand Down
14 changes: 14 additions & 0 deletions scripts/install_anvil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Install Anvil


BASE_DIR="${XDG_CONFIG_HOME:-$HOME}"
FOUNDRY_DIR="${FOUNDRY_DIR-"$BASE_DIR/.foundry"}"
FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin"

curl -L https://foundry.paradigm.xyz | bash
# Extract the source path from the download result
echo "foundryup_path: $FOUNDRY_BIN_DIR"
# run foundryup
$FOUNDRY_BIN_DIR/foundryup
21 changes: 13 additions & 8 deletions tests/waku_rln_relay/test_rln_group_manager_onchain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ else:
{.push raises: [].}

import
std/[options, osproc, sequtils, deques, streams, strutils, tempfiles],
std/[options, os, osproc, sequtils, deques, streams, strutils, tempfiles],
stew/[results, byteutils],
stew/shims/net as stewNet,
testutils/unittests,
Expand Down Expand Up @@ -117,6 +117,15 @@ proc createEthAccount(): Future[(keys.PrivateKey, Address)] {.async.} =

return (pk, acc)

proc getAnvilPath(): string =
var anvilPath = ""
if existsEnv("XDG_CONFIG_HOME"):
anvilPath = joinPath(anvilPath, os.getEnv("XDG_CONFIG_HOME", ""))
else:
anvilPath = joinPath(anvilPath, os.getEnv("HOME", ""))
anvilPath = joinPath(anvilPath, ".foundry/bin/anvil")
return $anvilPath

# Runs Anvil daemon
proc runAnvil(): Process =
# Passed options are
Expand All @@ -126,13 +135,9 @@ proc runAnvil(): Process =
# --chain-id Chain ID of the network.
# See anvil documentation https://book.getfoundry.sh/reference/anvil/ for more details
try:
let installAnvil = startProcess("cargo", args = ["install", "--git", "https://github.com/foundry-rs/foundry", "--profile", "local", "--locked", "anvil"], options = {poUsePath})
let anvilExitCode = waitForExit(installAnvil)
if anvilExitCode != 0:
error "Anvil installation failed", anvilExitCode
raise newException(CatchableError, "Anvil installation failed: " & $anvilExitCode)

let runAnvil = startProcess("anvil", args = ["--port", "8540", "--gas-limit", "300000000000000", "--balance", "10000", "--chain-id", "1337"], options = {poUsePath})
let anvilPath = getAnvilPath()
debug "Anvil path", anvilPath
let runAnvil = startProcess(getAnvilPath(), args = ["--port", "8540", "--gas-limit", "300000000000000", "--balance", "10000", "--chain-id", "1337"], options = {poUsePath})
let anvilPID = runAnvil.processID

# We read stdout from Anvil to see when daemon is ready
Expand Down

0 comments on commit 5635ddf

Please sign in to comment.