-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start script for smoke tests * validate FULLNODE_API_INFO is set and use value * stash * getting output; RPC returning 0 code and not hitting endpoint * formatting for individual tests * attempted fixups * line splitting for pretty-ness * fix token errors * cleanup * cleanup and iterate over multiple endpoints * figure out nuance with variable expansion * error with http1 and using curl calls * fix malformated JSON * output * its working and it looks good * add balance to list for testing * print http code * color output and display results of tests * remove unwrap call from wallet_api * round out wallet smoke tests * add smoke-test recipe to makefile * add more endpoints * smoke test documentation and state endpoints * add state documentation * use temp directory and setup with auth api-info * wrong names for state api endpoints * 500 is still a passing test * add state_replay method * No longer need to run forest; update docs
- Loading branch information
1 parent
7d5b333
commit bf3936a
Showing
4 changed files
with
110 additions
and
1 deletion.
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
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,23 @@ | ||
|
||
# Running Smoke Tests for Forest's RPC API | ||
|
||
## Prerequisites | ||
The only requirement for running these smoke tests is that Forest is installed and on your system PATH. | ||
|
||
## Running the Tests | ||
* Use `make install` to create a binary on your path | ||
* Run `make smoke-test` | ||
|
||
This will execute a blank request to all endpoints listed defined and check the HTTP | ||
status code of the response. If a response is received, this should be considered a good | ||
test, even if an error has occured. No parameters are passed to the API endpoints. | ||
An `OK` will be displayed if a test passes, and a `FAIL` will be displayed with an HTTP/curl code | ||
if a test fails. | ||
|
||
## Adding Future Endpoints | ||
Endpoints in the script `./scripts/smoke_test.sh` are stored in an array identified as `RPC_ENDPOINTS`. | ||
|
||
Add the endpoint identifier minus the prefix `Forest` to the module that it belongs to (ie gas, net, state, etc) | ||
or add a new section if a new API is added. | ||
|
||
This should be checked during the review process if new API methods are added to keep this script and test suite up to date. |
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,79 @@ | ||
#!/bin/bash | ||
|
||
# set temporary configuration | ||
FOREST_CONFIG="/tmp/temp_config.toml" | ||
echo "encrypt_keystore=false" > $FOREST_CONFIG | ||
|
||
# start forest daemon | ||
RUST_LOG=off forest -c $FOREST_CONFIG > /dev/null & | ||
|
||
# get token and multiaddr info | ||
FULL_ADDR=$(forest -c $FOREST_CONFIG auth api-info -p admin) | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
|
||
# extract token from auth api-info output | ||
TOKEN="$(cut -d':' -f1 <<< $FULL_ADDR)" | ||
TOKEN=${TOKEN#"FULLNODE_API_INFO=\""} | ||
|
||
# set headers for http requests | ||
AUTH_HEADER="Authorization: Bearer ${TOKEN}" | ||
CONTENT_TYPE_HEADER="Content-Type: application/json-rpc" | ||
|
||
# Wallet | ||
RPC_ENDPOINTS=("WalletList" "WalletBalance" "WalletDefaultAddress" "WalletExport" "WalletHas" "WalletImport" "WalletNew") | ||
RPC_ENDPOINTS+=("WalletSetDefault" "WalletSign" "WalletVerify") | ||
|
||
# Sync | ||
RPC_ENDPOINTS+=("SyncCheckBad" "SyncMarkBad" "SyncState" "SyncSubmitBlock") | ||
|
||
# Message Pool | ||
RPC_ENDPOINTS+=("MpoolEstimateGasPrice" "MpoolGetNonce" "MpoolPending" "MpoolPush" "MpoolPushMessage" "MpoolSelect") | ||
|
||
# Chain | ||
RPC_ENDPOINTS+=("ChainGetMessage" "ChainReadObj" "ChainHasObj" "ChainGetBlockMessages" "ChainGetTipsetByHeight" "ChainGetGenesis") | ||
RPC_ENDPOINTS+=("ChainHead" "ChainHeadSubscription" "ChainNotify" "ChainTipSetWeight" "ChainGetBlock" "ChainGetTipSet") | ||
RPC_ENDPOINTS+=("ChainGetRandomnessFromTickets" "ChainGetRandomnessFromBeacon") | ||
|
||
# Auth | ||
RPC_ENDPOINTS+=("AuthNew" "AuthVerify") | ||
|
||
# Net | ||
RPC_ENDPOINTS+=("NetAddrsListen" "NetPeers" "NetConnect" "NetDisconnect") | ||
|
||
# Common | ||
RPC_ENDPOINTS+=("Version") | ||
|
||
# Gas | ||
RPC_ENDPOINTS+=("GasEstimateFeeCap" "GasEstimateGasPremium" "GasEstimateGasLimit" "GasEstimateMessageGas") | ||
|
||
# State | ||
RPC_ENDPOINTS+=("StateMinerSectors" "StateCall" "StateMinerDeadlines" "StateSectorPrecommitInfo" "StateMinerInfo") | ||
RPC_ENDPOINTS+=("StateSectorGetInfo" "StateMinerProvingDeadline" "StateMinerFaults" "StateAllMinerFaults") | ||
RPC_ENDPOINTS+=("StateMinerRecoveries" "StateMinerPartitions" "StateReplay" "StateNetworkName" "StateNetworkVersion") | ||
RPC_ENDPOINTS+=("StateGetActor" "StateAccountKey" "StateLookupId" "StateMarketBalance" "StateMarketDeals") | ||
RPC_ENDPOINTS+=("StateGetReceipt" "StateWaitMsg" "MinerCreateBlock" "StateMinerSectorAllocated" "StateMinerPreCommitDepositForPower") | ||
RPC_ENDPOINTS+=("StateMinerInitialPledgeCollateral" "MinerGetBaseInfo") | ||
|
||
|
||
# send requests programmatically | ||
for endpoint in ${RPC_ENDPOINTS[@]}; do | ||
METHOD="Filecoin.${endpoint}" | ||
REQUEST_BODY="{\"jsonrpc\": \"2.0\", \"method\": \"$METHOD\", \"params\":[], \"id\": 0}" | ||
|
||
RESPONSE_CODE=$(curl -w "%{http_code}" -s -o /dev/null -X POST -H "$CONTENT_TYPE_HEADER" -H "$AUTH_HEADER" -d "$REQUEST_BODY" http://127.0.0.1:1234/rpc/v0) | ||
|
||
# a response is a response and considered a passing test | ||
# we are not passing params to endpoints so some methods will fail due to lack of params | ||
if [ $RESPONSE_CODE = '200' ] || [ $RESPONSE_CODE = '500' ]; then | ||
echo -e "${METHOD} ${GREEN} OK ${NC}" | ||
else | ||
echo -e "${METHOD} ${RED} FAIL ${RESPONSE_CODE} ${NC}" | ||
fi | ||
|
||
done | ||
|
||
# Kill forest daemon | ||
ps -ef | grep forest | grep -v grep | awk '{print $2}' | xargs kill |