Skip to content

Commit

Permalink
wip: patch w/ bifrost-gateway, will be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 21, 2023
1 parent 323a218 commit 6727be0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,16 @@ test_config_set() {
test_cmp cfg_set_expected cfg_set_actual
}

test_init_ipfs_addresses() {
# overwrites the gateway and api addresses according to environmental variables.
test_expect_success "updating the addresses succeeds" '
([ ! -z $TEST_NODE_GWAY_MADDR ] && ipfs config Addresses.Gateway $TEST_NODE_GWAY_MADDR || true) &&
([ ! -z $TEST_NODE_API_MADDR ] && ipfs config Addresses.API $TEST_NODE_API_MADDR || true)
'
}

test_init_ipfs() {


# we set the Addresses.API config variable.
# the cli client knows to use it, so only need to set.
# todo: in the future, use env?

test_expect_success "ipfs init succeeds" '
export IPFS_PATH="$(pwd)/.ipfs" &&
ipfs init --profile=test > /dev/null &&
test_init_ipfs_addresses
ipfs init --profile=test > /dev/null
'

test_expect_success "prepare config -- mounting" '
Expand All @@ -219,6 +211,7 @@ test_init_ipfs() {
test_config_set Mounts.IPNS "$(pwd)/ipns" ||
test_fsh cat "\"$IPFS_PATH/config\""
'

}

test_config_ipfs_gateway_writable() {
Expand Down Expand Up @@ -254,7 +247,7 @@ test_set_address_vars() {
API_ADDR=$(convert_tcp_maddr $API_MADDR) &&
API_PORT=$(port_from_maddr $API_MADDR) &&
[ -z "${TEST_GWAY_MADDR}" ] && GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") || GWAY_MADDR=${TEST_GWAY_MADDR} &&
GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") &&
GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
GWAY_PORT=$(port_from_maddr $GWAY_MADDR)
'
Expand Down Expand Up @@ -294,6 +287,17 @@ test_launch_ipfs_daemon() {
pollEndpoint -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
'

test_expect_success "start bifrost gateway" '
PROXY_GATEWAY_URL=http://$GWAY_ADDR KUBO_RPC_URL=http://$API_ADDR GOLOG_LOG_LEVEL="bifrost-gateway=debug" bifrost-gateway --gateway-port 9090 &
BIFROST_PID=$! &&
GWAY_MADDR=/ip4/127.0.0.1/tcp/9090 &&
GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
GWAY_PORT=$(port_from_maddr $GWAY_MADDR) &&
pollEndpoint -host=$GWAY_MADDR -v -tout=1s -tries=60
'
}

test_launch_ipfs_daemon_without_network() {
Expand Down Expand Up @@ -361,6 +365,14 @@ test_kill_ipfs_daemon() {
test_expect_success "'ipfs daemon' can be killed" '
test_kill_repeat_10_sec $IPFS_PID
'

test_expect_success "'bifrost-gateway' is still running" '
kill -0 $BIFROST_PID
'

test_expect_success "'bifrost-gateway' can be killed" '
test_kill_repeat_10_sec $BIFROST_PID
'
}

test_curl_resp_http_code() {
Expand Down

0 comments on commit 6727be0

Please sign in to comment.