solidity/test/cmdlineTests/~linking/test.sh
Kamil Śliwak 6b061ba696 cmdlineTests: Extract script-based test out of cmdlineTests.sh
- Just extraction, with as few changes to the code as possible.
2023-06-02 16:10:40 +02:00

23 lines
744 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh"
printTask "Testing linking itself..."
SOLTMPDIR=$(mktemp -d)
(
cd "$SOLTMPDIR"
echo 'library L { function f() public pure {} } contract C { function f() public pure { L.f(); } }' > x.sol
msg_on_error --no-stderr "$SOLC" --bin -o . x.sol
# Explanation and placeholder should be there
grep -q '//' C.bin && grep -q '__' C.bin
# But not in library file.
grep -q -v '[/_]' L.bin
# Now link
msg_on_error "$SOLC" --link --libraries x.sol:L=0x90f20564390eAe531E810af625A22f51385Cd222 C.bin
# Now the placeholder and explanation should be gone.
grep -q -v '[/_]' C.bin
)
rm -r "$SOLTMPDIR"