diff --git a/10 Notes/Running functional tests in status-go.md b/10 Notes/Running functional tests in status-go.md index cd5d7b5..805601a 100644 --- a/10 Notes/Running functional tests in status-go.md +++ b/10 Notes/Running functional tests in status-go.md @@ -197,7 +197,7 @@ run_functional_tests.sh "test_accept_request_address_for_transaction and wakuV2L run_functional_tests.sh "test_accept_request_address_for_transaction and wakuV2LightClient_True" ``` -When the argument is provided you the `run_functional_tests.sh` will first tell you which tests will be run and let you decide to continue or not: +When the argument is provided the `run_functional_tests.sh` will first tell you which tests will be run and let you decide to continue or not: ```bash Discovering tests to be run... diff --git a/10 Notes/Using status-backend to test status-go API.md b/10 Notes/Using status-backend to test status-go API.md new file mode 100644 index 0000000..ca953ae --- /dev/null +++ b/10 Notes/Using status-backend to test status-go API.md @@ -0,0 +1,120 @@ +Here are some basic steps to follow: + +### Step 1: Initialize the application + +```bash +curl -sS http://127.0.0.1:45453/statusgo/InitializeApplication \ + -H 'Content-Type: application/json' \ + -d '{"dataDir":"/tmp/status-go-test"}' +``` + +### Step 2: Create an account (if you don't have one) OR login + +```bash +curl -sS http://127.0.0.1:45453/statusgo/CreateAccountAndLogin \ + -H 'Content-Type: application/json' \ + -d '{ + "rootDataDir": "/tmp/status-go-test", + "displayName": "TestUser", + "password": "test123456", + "customizationColor": "blue" + }' +``` + +or if you already have account: + +```bash +curl -sS http://127.0.0.1:45453/statusgo/LoginAccount -X POST -H 'Content-Type: application/json' -d '{ + "rootDataDir": "/tmp/status-go-test", + "keyUid": "0x9b755874a92bcc2d20c730fc76d451f44b39868cc8fbd31f2ff74907e299e7fd", + "password": "test123456" +}' +``` + +If you see `{"error":""}` as the output it means the command was successful and there is no error. + +If you try to call the API before login, you will get the following error (example): + +```bash +❯ curl -sS http://127.0.0.1:45453/statusgo/CallRPC -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"wakuext_getArchiveDistributionPreference","params":[]}' +{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"the method wakuext_getArchiveDistributionPreference does not exist/is not available"}} +``` + + +I did not record the output of the `CreateAccountAndLogin` but in the returned response object you should be able to find the `keyUid` mentioned above. It is also included in the response from `InitializeApplication` for each existing account: + +```bash +curl -sS http://127.0.0.1:45453/statusgo/InitializeApplication \ + -H 'Content-Type: application/json' \ + -d '{"dataDir":"/tmp/status-go-test"}' +{"accounts":[{"name":"TestUser","timestamp":1762236462,"identicon":"","colorHash":[[3,9],[5,18],[3,24],[5,22],[4,6],[5,23],[2,3],[4,24],[1,27],[5,21],[3,11]],"colorId":3,"customizationColor":"blue","keycard-pairing":"","key-uid":"0x9b755874a92bcc2d20c730fc76d451f44b39868cc8fbd31f2ff74907e299e7fd","images":null,"kdfIterations":3200,"hasAcceptedTerms":true}],"centralizedMetricsInfo":{"enabled":false,"userConfirmed":false,"userID":""}} +``` + +The `keyUid` is a unique identifier for each account in status-go. You can also find it by looking at the database filenames in the data directory. + +When you create an account, status-go creates database files with a specific naming pattern: + +``` +