This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding testable docker behavior
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
- Loading branch information
Showing
15 changed files
with
167 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
!crates | ||
!tests | ||
!Cargo.* | ||
!tools/init.sh | ||
|
||
!LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use clap::Args; | ||
|
||
#[derive(Args, Debug)] | ||
pub(crate) struct PeerId { | ||
#[arg(long = "from-slice")] | ||
pub(crate) from_slice: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
crates/topos/tests/snapshots/tce__can_get_a_peer_id_from_a_seed.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
source: crates/topos/tests/tce.rs | ||
expression: result | ||
--- | ||
12D3KooWRhFCXBhmsMnur3up3vJsDoqWh4c39PKXgSWwzAzDHNLn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if ! command -v jq &> /dev/null | ||
then | ||
echo "jq could not be found" | ||
exit | ||
fi | ||
|
||
JQ=$(which jq) | ||
TOPOS_BIN=./topos | ||
PEER_LIST_PATH=/tmp/shared/peer_ids.json | ||
NODE_LIST_PATH=/tmp/shared/peer_nodes.json | ||
NODE="http://$HOSTNAME:1340" | ||
|
||
case "$1" in | ||
|
||
"boot") | ||
echo "Generating peer list file..." | ||
$JQ -n --arg PEER $($TOPOS_BIN tce peer-id --from-slice=$TCE_LOCAL_KS) '[$PEER]' > $PEER_LIST_PATH | ||
echo "Peer list file have been successfully generated" | ||
|
||
echo "Generating node list file..." | ||
$JQ -n --arg NODE $NODE '{"nodes": [$NODE]}' > $NODE_LIST_PATH | ||
echo "Peer nodes list have been successfully generated" | ||
|
||
echo "Starting boot node..." | ||
exec "$TOPOS_BIN" "${@:2}" | ||
;; | ||
|
||
*) | ||
if [[ ! -z ${LOCAL_TEST_NET+x} ]]; then | ||
until [ -f "$PEER_LIST_PATH" ] | ||
do | ||
echo "Waiting 1s for peer_list file $PEER_LIST_PATH to be created by boot container..." | ||
sleep 1 | ||
done | ||
|
||
PEER=$($TOPOS_BIN tce peer-id --from-slice=$HOSTNAME) | ||
cat <<< $($JQ --arg PEER $PEER '. += [$PEER]' $PEER_LIST_PATH) > $PEER_LIST_PATH | ||
|
||
export TCE_LOCAL_KS=$HOSTNAME | ||
|
||
until [ -f "$NODE_LIST_PATH" ] | ||
do | ||
echo "Waiting 1s for node_list file $NODE_LIST_PATH to be created by boot container..." | ||
sleep 1 | ||
done | ||
|
||
cat <<< $($JQ --arg NODE $NODE '.nodes += [$NODE]' $NODE_LIST_PATH) > $NODE_LIST_PATH | ||
fi | ||
|
||
exec "$TOPOS_BIN" "$@" | ||
;; | ||
|
||
esac |