Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Update CI; fix seed logging (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabijanC authored Sep 21, 2022
1 parent 668db7d commit 8a27496
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
23 changes: 17 additions & 6 deletions scripts/image_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,33 @@ IMAGE=shardlabs/starknet-devnet
function test_and_push(){
local tagged_image="$IMAGE:$1"

echo "Run $tagged_image in background; sleep to allow it to start"
local container_name="devnet"
docker run -d -p 127.0.0.1:5050:5050 --name "$container_name" --rm "$tagged_image"

local internal_port="5050"
local external_address="127.0.0.1:5050"

echo "Runing $tagged_image in background; sleeping to allow it to start"
docker run -d \
-p "$external_address:$internal_port" \
--name "$container_name" \
"$tagged_image" \
--port "$internal_port"

sleep 10 # alternatively check in a loop

# logging can be helpful if Devnet exited early
docker logs "$container_name"

echo "Checking if devnet instance is alive"
if [ ! -z $REMOTE ]; then
ssh remote-docker curl localhost:5050/is_alive -w "\n"
ssh remote-docker curl "$external_address/is_alive" -w "\n"
else
curl localhost:5050/is_alive -w "\n"
curl "$external_address/is_alive" -w "\n"
fi

docker kill "$container_name"

docker push "$tagged_image"

docker rm -f "$container_name"
}

SHA1_TAG="${CIRCLE_SHA1}${ARCH_SUFFIX}"
Expand Down
1 change: 1 addition & 0 deletions scripts/install_dev_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ echo "poetry: $(poetry --version)"

# install dependencies
poetry install
poetry lock --check
npm ci
10 changes: 5 additions & 5 deletions starknet_devnet/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def __init__(self, starknet_wrapper):
self.starknet_wrapper = starknet_wrapper
self.__n_accounts = starknet_wrapper.config.accounts
self.__initial_balance = starknet_wrapper.config.initial_balance

self.__seed = starknet_wrapper.config.seed
if self.__seed is None:
self.__seed = random.getrandbits(32)

self.list = []

self.__generate()
Expand All @@ -42,11 +46,7 @@ def add(self, account):
def __generate(self):
"""Generates accounts without deploying them"""
random_generator = random.Random()
self.__initial_balance = self.__initial_balance

random_generator.seed(
self.__seed if self.__seed is not None else random_generator.getrandbits(32)
)
random_generator.seed(self.__seed)

for _ in range(self.__n_accounts):
private_key = random_generator.getrandbits(128)
Expand Down

0 comments on commit 8a27496

Please sign in to comment.