Icepick Solana: Add End-to-End Tests
This commit is contained in:
parent
767e7a7df2
commit
f5ca0841cb
|
@ -0,0 +1,22 @@
|
||||||
|
# Solana End to End Tests
|
||||||
|
|
||||||
|
This test demonstrates that Keyfork can be loaded, a key can be derived, and a
|
||||||
|
transaction can be performed using an SPL Token.
|
||||||
|
|
||||||
|
We assume for these purposes that an account already exists with enough of the
|
||||||
|
token to be usable. The flow should be as follows:
|
||||||
|
|
||||||
|
1. In one terminal, `run-offline.sh` should be started, with the mnemonic
|
||||||
|
entered, to emulate the procurement and operation of the Offline Machine and
|
||||||
|
the recovery of the shard.
|
||||||
|
2. In another terminal, `run-online.sh` should be started, with the
|
||||||
|
"sender address" being the address from the mnemonic, the "recipient
|
||||||
|
address" being the address of any other previously created account, the
|
||||||
|
token name being IPDBG or some other devnet token, and the token amount
|
||||||
|
being the amount to transfer - ideally a low amount.
|
||||||
|
3. Upon entering all the fields, the inputs should be transferred to the
|
||||||
|
offline "machine" for validation. Once validated, the offline machine will
|
||||||
|
derive the key, sign the transaction, and send it to the online machine for
|
||||||
|
transmission.
|
||||||
|
4. The online machine will return a signature that can be used to validate the
|
||||||
|
transaction on the Solana Devnet Blockchain Explorer.
|
|
@ -0,0 +1,51 @@
|
||||||
|
# vim: set ft=dockerfile:
|
||||||
|
FROM stagex/busybox:sx2024.11.0@sha256:3d128909dbc8e7b6c4b8c3c31f4583f01a307907ea179934bb42c4ef056c7efd AS busybox
|
||||||
|
FROM stagex/binutils:sx2024.11.0@sha256:eff721a796fdfba8c34e21a487b0e376fb55ca2633524926998f1660fbb810de AS binutils
|
||||||
|
FROM stagex/musl:sx2024.11.0@sha256:d7f6c365f5724c65cadb2b96d9f594e46132ceb366174c89dbf7554897f2bc53 AS musl
|
||||||
|
FROM stagex/rust:sx2024.11.0@sha256:f23fa04c29ab0250b39c38ee1cc4394a1ea3ec91b865070716a585d2b96389ed AS rust
|
||||||
|
FROM stagex/gcc:sx2024.11.0@sha256:49ea63c81c65f8be25c242b7e64f2758b23effdaafb458b5862d0f23ec803075 AS gcc
|
||||||
|
FROM stagex/llvm:sx2024.11.0@sha256:27da8a38ec621317dbafbf1dbdefb07a5b007d1d28ae86393480209652ed3770 AS llvm
|
||||||
|
FROM stagex/libunwind:sx2024.11.0@sha256:290b8d183a467edc55e338471632f2e40859aef92a4eecf12415ca29b9c16e9f AS libunwind
|
||||||
|
FROM stagex/openssl:sx2024.11.0@sha256:8e3eb24b4d21639f7ea204b89211d8bc03a2e1b729fb1123f8d0b3752b4beaa1 AS openssl
|
||||||
|
FROM stagex/zlib:sx2024.11.0@sha256:09d63654e27decb6147f1b23005d539e30db8e53eb2d284e824bcf4d4e7c3c11 AS zlib
|
||||||
|
FROM stagex/ca-certificates:sx2024.11.0@sha256:a84695f983a448a82acfe78af11f33c6a66b27124266e1fdc3ecfb8dc5852573 AS ca-certificates
|
||||||
|
FROM stagex/clang:sx2024.11.0@sha256:c26069d378f36c06b5d91e3aba907521ec79eb0864d65a4c28a2db17947ec25f AS clang
|
||||||
|
FROM stagex/pkgconf:sx2024.11.0@sha256:05b4ac6b931cd81fe5aff48c5a77bb9ae472e2bfbce3cc7d4698c670712d4409 AS pkgconf
|
||||||
|
FROM stagex/jq:sx2024.11.0@sha256:f54ab8399ca0b373d34a61e2aadd0bb28fac54841c9495043fd477316ceefd7c AS jq
|
||||||
|
|
||||||
|
FROM scratch AS base
|
||||||
|
|
||||||
|
|
||||||
|
COPY --from=busybox . /
|
||||||
|
COPY --from=binutils . /
|
||||||
|
COPY --from=musl . /
|
||||||
|
COPY --from=rust . /
|
||||||
|
COPY --from=gcc . /
|
||||||
|
COPY --from=llvm . /
|
||||||
|
COPY --from=libunwind . /
|
||||||
|
COPY --from=openssl . /
|
||||||
|
COPY --from=zlib . /
|
||||||
|
COPY --from=ca-certificates . /
|
||||||
|
COPY --from=clang . /
|
||||||
|
COPY --from=pkgconf . /
|
||||||
|
COPY --from=jq . /
|
||||||
|
|
||||||
|
COPY Cargo.toml /app/Cargo.toml
|
||||||
|
COPY Cargo.lock /app/Cargo.lock
|
||||||
|
COPY .cargo /app/.cargo
|
||||||
|
COPY crates /app/crates
|
||||||
|
COPY icepick.toml /
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN cargo fetch --locked
|
||||||
|
RUN cargo build --frozen --release --target x86_64-unknown-linux-musl --bin icepick
|
||||||
|
RUN cargo build --frozen --release --target x86_64-unknown-linux-musl --bin icepick-sol
|
||||||
|
RUN <<EOF
|
||||||
|
cargo fetch --locked
|
||||||
|
cargo build --frozen --release --target x86_64-unknown-linux-musl --bin icepick
|
||||||
|
cargo build --frozen --release --target x86_64-unknown-linux-musl --bin icepick-sol
|
||||||
|
cp /app/target/x86_64-unknown-linux-musl/release/icepick /usr/bin
|
||||||
|
cp /app/target/x86_64-unknown-linux-musl/release/icepick-sol /usr/bin
|
||||||
|
EOF
|
||||||
|
|
||||||
|
WORKDIR /
|
|
@ -0,0 +1,10 @@
|
||||||
|
# vim: set ft=dockerfile:
|
||||||
|
|
||||||
|
FROM stagex/keyfork:sx2024.11.0@sha256:5c4701d26b884c2b3e7579377d73d21968ad773057b8e8c736bab3e177a26360 AS keyfork
|
||||||
|
FROM git.distrust.co/public/icepick-sol:base
|
||||||
|
COPY --from=keyfork . /
|
||||||
|
|
||||||
|
COPY e2e-tests/solana/offline.sh /offline.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/sh"]
|
||||||
|
CMD ["/offline.sh"]
|
|
@ -0,0 +1,25 @@
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Loading Keyfork by mnemonic"
|
||||||
|
export KEYFORKD_SOCKET_PATH=/tmp/keyforkd.sock
|
||||||
|
( keyfork recover mnemonic & )
|
||||||
|
|
||||||
|
while test ! -e $KEYFORKD_SOCKET_PATH; do sleep 1; done
|
||||||
|
|
||||||
|
echo "Waiting for inputs from online system..."
|
||||||
|
while test ! -f /data/input.json; do sleep 1; done
|
||||||
|
|
||||||
|
from_address="$(jq -r .from_address /data/input.json)"
|
||||||
|
to_address="$(jq -r .to_address /data/input.json)"
|
||||||
|
token_name="$(jq -r .token_name /data/input.json)"
|
||||||
|
token_amount="$(jq -r .token_amount /data/input.json)"
|
||||||
|
blockhash="$(jq -r .blockhash /data/input.json)"
|
||||||
|
token_address="$(icepick sol get-token-address "$token_name" | jq -r .blob)"
|
||||||
|
|
||||||
|
echo "Do these values look correct? If not, press ctrl-c. Otherwise, press Enter."
|
||||||
|
jq . /data/input.json
|
||||||
|
read _
|
||||||
|
|
||||||
|
echo "Creating and signing transaction"
|
||||||
|
|
||||||
|
icepick sol transfer-token "$token_amount" "$token_address" "$to_address" "$from_address" | icepick sol sign "$blockhash" > /data/output.json
|
|
@ -0,0 +1,8 @@
|
||||||
|
# vim: set ft=dockerfile:
|
||||||
|
|
||||||
|
FROM git.distrust.co/public/icepick-sol:base
|
||||||
|
|
||||||
|
COPY e2e-tests/solana/online.sh /online.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/sh"]
|
||||||
|
CMD ["/online.sh"]
|
|
@ -0,0 +1,32 @@
|
||||||
|
printf "%s" "Public key of the sender address: "
|
||||||
|
read from_address
|
||||||
|
|
||||||
|
printf "%s" "Public key of the recipient address: "
|
||||||
|
read to_address
|
||||||
|
|
||||||
|
printf "%s" "Name of the token to transfer: "
|
||||||
|
read token_name
|
||||||
|
|
||||||
|
printf "%s" "Amount of token to transfer: "
|
||||||
|
read token_amount
|
||||||
|
|
||||||
|
echo "Acquiring blockhash..."
|
||||||
|
blockhash="$(icepick sol get-blockhash --cluster devnet | jq -r .blob)"
|
||||||
|
|
||||||
|
echo "Saving information to file"
|
||||||
|
|
||||||
|
cat <<EOF > /data/input.json
|
||||||
|
{
|
||||||
|
"from_address": "$from_address",
|
||||||
|
"to_address": "$to_address",
|
||||||
|
"token_name": "$token_name",
|
||||||
|
"token_amount": "$token_amount",
|
||||||
|
"blockhash": "$blockhash"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Waiting for signed transaction..."
|
||||||
|
while test ! -f /data/output.json; do sleep 1; done
|
||||||
|
|
||||||
|
echo "Broadcasting transaction"
|
||||||
|
icepick sol broadcast --cluster devnet < /data/output.json
|
|
@ -0,0 +1,11 @@
|
||||||
|
set -eu
|
||||||
|
export DOCKER_BUILDKIT=1
|
||||||
|
|
||||||
|
image="git.distrust.co/public/icepick-sol"
|
||||||
|
|
||||||
|
pushd "$(dirname $0)"
|
||||||
|
docker build -t "$image:base" -f base.Containerfile ../..
|
||||||
|
docker build -t "$image:offline" -f offline.Containerfile ../..
|
||||||
|
|
||||||
|
mkdir -p data
|
||||||
|
docker run -it -v "$PWD/data:/data" "$image:offline"
|
|
@ -0,0 +1,14 @@
|
||||||
|
set -eu
|
||||||
|
export DOCKER_BUILDKIT=1
|
||||||
|
|
||||||
|
image="git.distrust.co/public/icepick-sol"
|
||||||
|
|
||||||
|
pushd "$(dirname $0)"
|
||||||
|
docker build -t "$image:base" -f base.Containerfile ../..
|
||||||
|
docker build -t "$image:online" -f online.Containerfile ../..
|
||||||
|
|
||||||
|
mkdir -p data
|
||||||
|
# remove stale data if it exists
|
||||||
|
rm data/input.json || true
|
||||||
|
rm data/output.json || true
|
||||||
|
docker run -it -v "$PWD/data:/data" "$image:online"
|
Loading…
Reference in New Issue