Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Commit ce944c3

Browse files
author
Piotr Stachyra
committed
Manual scenarios and some testing helper scripts for #258
1 parent 1f0dd20 commit ce944c3

File tree

3 files changed

+309
-0
lines changed

3 files changed

+309
-0
lines changed

test/manual/258/create_addresses.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
port=46380 # Note: Daedalus port can be retrieved with the following command `lsof -i -P -n | grep LISTEN` (cardano-n port)
4+
wallet_id="Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW"
5+
account_index=2147483648
6+
7+
for i in {1..50000}
8+
do
9+
10+
echo "Address no: $i"
11+
12+
curl -X POST https://localhost:$port/api/v1/addresses \
13+
-H "Accept: application/json; charset=utf-8" \
14+
-H "Content-Type: application/json; charset=utf-8" \
15+
--cert ~/.local/share/Daedalus/staging/tls/client/client.pem \
16+
--cacert ~/.local/share/Daedalus/staging/tls/client/ca.crt \
17+
-d '{
18+
"accountIndex": '"$account_index"',
19+
"walletId": "'"$wallet_id"'"
20+
}'
21+
22+
done

test/manual/258/get_addresses.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# 1.
4+
5+
port=46380 #Note: Daedalus port can be retrieved with the following command `lsof -i -P -n | grep LISTEN` (cardano-n port)
6+
wallet_id="Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW"
7+
account_index=2147483648
8+
filename="addresses50k.txt"
9+
10+
echo "[" >> $filename
11+
for i in {1..50000}
12+
do
13+
url="https://localhost:$port/api/v1/wallets/$wallet_id/accounts/$account_index/addresses?per_page=50&page=$i"
14+
curl -kX GET $url \
15+
-H "Accept: application/json; charset=utf-8" \
16+
-H "Content-Type: application/json; charset=utf-8" \
17+
--cert ~/.local/share/Daedalus/staging/tls/client/client.pem \
18+
--cacert ~/.local/share/Daedalus/staging/tls/client/ca.crt --http1.1 | python -m json.tool | grep id | sed -e 's/"id"://g' | tr -s '[:blank:]' >> $filename
19+
20+
done
21+
22+
truncate -s-2 $filename
23+
echo >> $filename
24+
echo "]" >> $filename
25+

test/manual/258/scenarios.md

+262
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
2+
# Context
3+
4+
This document describes manual test procedure for https://github.com/input-output-hk/cardano-wallet/issues/258.
5+
6+
The change here introduces new endpoint `POST /api/v1/wallets/{wid}/accounts/{accix}/addresses` which allows batch import of unused addresses into the wallet's account. This functionality is targeted to exchanges and the possible use case has been described in the Wallet's API documentation https://input-output-hk.github.io/cardano-wallet/#section/Common-Use-Cases/Importing-(Unused)-Addresses-From-a-Previous-Node-(or-Version).
7+
8+
There have been automated integration tests added for testing new endpoint however there are still areas that need to be tested manually as they cannot be easily instrumented using integration tests. These are:
9+
- doing batch import of addresses while wallet is being restored
10+
- importing large amount of addresses (50k)
11+
12+
13+
# Data
14+
15+
Following wallets can be used for testing. These are _1.3.1_ wallets existing on staging blockchain:
16+
1. `["quit", "elder", "useless", "love", "foster", "know", "glad", "muffin", "guitar", "shrimp", "glad", "liberty"]` - `Ae2tdPwUPEZLBbAHVdKg9uLBeHxZQjXeVguFWJNASbQ7vugfQbmwHqSFMVy`
17+
18+
2. `["clinic","nuclear","paddle","leg","lounge","fabric","claw","trick","divide","pretty", "argue", "fade"]` - `Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW`
19+
20+
3. `["offer","need","accuse","yellow","sibling","robust","view","rare","cry","picture", "weather", "love"]` - `Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW`
21+
22+
# Scenarios
23+
24+
## Test 1 - Batch import list of addresses while the wallet is restoring
25+
26+
### Summary:
27+
28+
This test includes importing unused addresses to the wallet that is being restored. Expected is that batch import can be successfully performed while the wallet is being restored.
29+
30+
## Prerequisites
31+
- Start a node connected to staging with `cardano-wallet` attached as described here -> https://github.com/input-output-hk/cardano-wallet/wiki/Building-Running-and-Testing-a-wallet-node. Have the node 100% synced.
32+
- Have a Daedalus staging installed and synced. Get Daedalus staging from https://buildkite.com/input-output-hk/daedalus.
33+
- Have a wallet already restored in the Daedalus staging. See above for possible wallet data.
34+
35+
36+
### Steps:
37+
1. In Daedalus, go to the restored wallet (see prerequisites) and create few addresses (Receive tab). Make sure addresses are not used.
38+
39+
2. Start restoring the same wallet that you have on Daedalus on the manually started node.
40+
41+
```
42+
curl -X POST https://localhost:8090/api/v1/wallets \
43+
-H "Accept: application/json; charset=utf-8" \
44+
-H "Content-Type: application/json; charset=utf-8" \
45+
--cert ./state-staging/tls/client/client.pem \
46+
--cacert ./state-staging/tls/client/ca.crt \
47+
-d '{
48+
"operation": "restore",
49+
"backupPhrase":["clinic","nuclear","paddle","leg","lounge","fabric","claw","trick","divide","pretty", "argue", "fade"],
50+
"assuranceLevel": "normal",
51+
"name": "test#258"
52+
}' --http1.1 | python -m json.tool
53+
```
54+
55+
3. Make sure wallet is restoring.
56+
57+
```
58+
curl -X GET https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW \
59+
-H "Accept: application/json; charset=utf-8" \
60+
-H "Content-Type: application/json; charset=utf-8" \
61+
--cert ./state-staging/tls/client/client.pem \
62+
--cacert ./state-staging/tls/client/ca.crt --http1.1 | python -m json.tool
63+
64+
```
65+
66+
4. Batch import addresses to the wallet that is being restored on the node. In the payload put two addresses previously created with Daedalus, but not used. And two that belong to different wallet.
67+
68+
```
69+
curl -X POST https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW/accounts/2147483648/addresses \
70+
-H "Accept: application/json; charset=utf-8" \
71+
-H "Content-Type: application/json; charset=utf-8" \
72+
--cert ./state-staging/tls/client/client.pem \
73+
--cacert ./state-staging/tls/client/ca.crt \
74+
-d '[
75+
"DdzFFzCqrhsq1fQf66snjqHdZyMB8FMB7DhKAY3cBvqtoo7jw2ZGYMRn36wQZhiHp2Krnf6p7izgky8gJmmCWgEUQBy984ucCn2rs4aY",
76+
"DdzFFzCqrhsofWdZGrC6jBAgFWroYcULQxpGDLsiYooG4sXE5HksbsAw4j9itz7jL1YNspCHdDX6A5SbFSuNYrqsk9Au7m9XFmNParGc",
77+
"DdzFFzCqrhtAercxp32BQUzjBXtgYXMPdYxkBSnhVSNQRwDvKEDRXy4k3FYCQerLGZKG4Cqvt514VdXUA9ihze6GtvFHWur3DRRjDexf",
78+
"DdzFFzCqrht9jruyiSZu4mQQcci9jupFS59pTv9xwFmdTwjTjfKinVXrKWxBWVmQWyVUcBMg4mZ2WD8godj4T7wMnkdWzqKjc3Bj8quL"
79+
]' --http1.1 | python -m json.tool
80+
```
81+
5. Wait until wallet gets restored on the node and check if imported addresses are available for the wallet's account.
82+
83+
a) get wallet's account id:
84+
```
85+
curl -X GET https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLBbAHVdKg9uLBeHxZQjXeVguFWJNASbQ7vugfQbmwHqSFMVy/accounts \
86+
-H "Accept: application/json; charset=utf-8" \
87+
-H "Content-Type: application/json; charset=utf-8" \
88+
--cert ./state-staging/tls/client/client.pem \
89+
--cacert ./state-staging/tls/client/ca.crt --http1.1 | python -m json.tool
90+
```
91+
92+
b) get addresses (set your account id instead of `2147483648` if needed):
93+
```
94+
curl -vX GET https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW/accounts/2147483648/addresses \
95+
-H "Accept: application/json; charset=utf-8" \
96+
-H "Content-Type: application/json; charset=utf-8" \
97+
--cert ./state-staging/tls/client/client.pem \
98+
--cacert ./state-staging/tls/client/ca.crt --http1.1 | python -m json.tool
99+
100+
```
101+
102+
### Expected:
103+
104+
4. Import should be successful. Two addresses should be imported successfully (the addresses generated in Daedalus). The other two addresses should be listed in the failures of the response, e.g.:
105+
106+
```
107+
{
108+
"data": {
109+
"failures": [
110+
"DdzFFzCqrhsq1fQf66snjqHdZyMB8FMB7DhKAY3cBvqtoo7jw2ZGYMRn36wQZhiHp2Krnf6p7izgky8gJmmCWgEUQBy984ucCn2rs4aY",
111+
"DdzFFzCqrhsofWdZGrC6jBAgFWroYcULQxpGDLsiYooG4sXE5HksbsAw4j9itz7jL1YNspCHdDX6A5SbFSuNYrqsk9Au7m9XFmNParGc",
112+
],
113+
"totalSuccess": 2
114+
},
115+
"meta": {
116+
"pagination": {
117+
"page": 1,
118+
"perPage": 1,
119+
"totalEntries": 1,
120+
"totalPages": 1
121+
}
122+
},
123+
"status": "success"
124+
}
125+
126+
```
127+
5. After wallet is restored all imported addresses are available for it's account.
128+
129+
130+
## Test 2 - Import large number of addresses
131+
132+
133+
### Summary:
134+
135+
This test includes:
136+
- generating 50k addresses on the wallet inside Daedalus staging node. All these generated addresses are obviously _not used_.
137+
- checking currently existing addresses on the wallet that exists on the node
138+
- Preparing the import request to be executed on the wallet that exists on the node
139+
- importing previously generated addresses into the wallet that exists on the node and investigating the results
140+
141+
### Prerequisites
142+
- have the same wallet synced on both: Daedalus staging and the node. (node should be started manually using this step-by-step https://github.com/input-output-hk/cardano-wallet/wiki/Building-Running-and-Testing-a-wallet-node)
143+
- both Daedalus node and manual node are synced.
144+
- wallets on both nodes are synced.
145+
146+
### Steps:
147+
1. Generate 50k addresses on Daedalus wallet. The following script can be used: [create_addresses.sh](./create_addresses.sh) (Please note that the script may take ~2h to complete)
148+
2. Get all addresses into the file using the script [get_addresses.sh](./get_addresses.sh) (The script gets all addresses into a file which then can be used in subsequent batch import request)
149+
3. Get all the addresses from the wallet that exists on the node and write them down.
150+
```
151+
curl -vX GET https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW/accounts/2147483648/addresses \
152+
-H "Accept: application/json; charset=utf-8" \
153+
-H "Content-Type: application/json; charset=utf-8" \
154+
--cert ./state-staging/tls/client/client.pem \
155+
--cacert ./state-staging/tls/client/ca.crt --http1.1 | python -m json.tool
156+
157+
```
158+
5. Attempt to import 50k addresses into the same wallet that exists on the node.
159+
```
160+
curl -X POST https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW/accounts/2147483648/addresses \
161+
-H "Accept: application/json; charset=utf-8" \
162+
-H "Content-Type: application/json; charset=utf-8" \
163+
--cert ~/wb/cardano-wallet/state-staging/tls/client/client.pem \
164+
--cacert ~/wb/cardano-wallet/state-staging/tls/client/ca.crt \
165+
-d @addresses50k.txt --http1.1 | python -m json.tool
166+
```
167+
168+
### Expected:
169+
The import should be successful. If there are any failures make sure that they concern addresses written down in step 3 above.
170+
Please note: the batch import request with 50k addresses took ~7-9 minutes on the local node for the following hardware spec: Ubuntu Linux, SSD, 16GB RAM, Intel Core i5 (8 cores).
171+
172+
Exemplary response:
173+
```
174+
{
175+
"data": {
176+
"failures": [
177+
"DdzFFzCqrhskD1VjKUAaViF4kfdtgyK3vH3HpGZ9sovnQTAz6g1AF1Q88EgzqyhMBtVCc56VvxRCpKQPm7V9Va9G8p8uTXEp3kkQ85W1",
178+
"DdzFFzCqrhsvmqQfb3GZ1vGqvLhUDptFDzFeW8Sb5JR15PMo1Mi2E2q3rjzxX1HyLEYRMuYCBVm2KHi7QFAtJoSDTFkTgXoLxicoGEqV",
179+
"DdzFFzCqrhsgQUEetVpWz1o1w6MxwH2FqNnDRwzSRhPbscVoWak73Nqe6oCnzcPjKWDioRygbHUS7HGTYFHx7cpTeTKHdTmxMkkFWWhL",
180+
"DdzFFzCqrht2TTuitt4gLeVpeKdvi8JEFCMMwgQN5iLcWyd4BEdCvC8k4dpNa1MseTkyjiveCQxQNnbX6xQt374o4iDnYctbdELgw8Q7"
181+
],
182+
"totalSuccess": 49956
183+
},
184+
"meta": {
185+
"pagination": {
186+
"page": 1,
187+
"perPage": 1,
188+
"totalEntries": 1,
189+
"totalPages": 1
190+
}
191+
},
192+
"status": "success"
193+
}
194+
```
195+
196+
197+
## Test 3 - Import large number of addresses while wallet is restoring
198+
199+
200+
### Summary:
201+
202+
This test case essentially combines the both scenarios above. The aim is to import a large amount of addresses while wallet is being restored and make sure there is no misbehaviour.
203+
204+
### Prerequisites
205+
- have the wallet synced on Daedalus staging.
206+
- have a node started using this step-by-step https://github.com/input-output-hk/cardano-wallet/wiki/Building-Running-and-Testing-a-wallet-node)
207+
- both Daedalus node and manual node are synced.
208+
209+
### Steps:
210+
1. Get all the *used* addresses from the Daedalus wallet and write them down. (Receive tab)
211+
2. Generate 50k addresses on Daedalus wallet. The following script can be used: [create_addresses.sh](./create_addresses.sh) (Please note that the script may take ~2h to complete)
212+
3. Get all addresses into the file using the script [get_addresses.sh](./get_addresses.sh) (The script gets all addresses into a file which then can be used in subsequent batch import request)
213+
4. On the manually started node: start restoring the same wallet that you have on Daedalus.
214+
215+
```
216+
curl -X POST https://localhost:8090/api/v1/wallets \
217+
-H "Accept: application/json; charset=utf-8" \
218+
-H "Content-Type: application/json; charset=utf-8" \
219+
--cert ./state-staging/tls/client/client.pem \
220+
--cacert ./state-staging/tls/client/ca.crt \
221+
-d '{
222+
"operation": "restore",
223+
"backupPhrase":["clinic","nuclear","paddle","leg","lounge","fabric","claw","trick","divide","pretty", "argue", "fade"],
224+
"assuranceLevel": "normal",
225+
"name": "test#258"
226+
}' --http1.1 | python -m json.tool
227+
```
228+
229+
5. Attempt to import 50k addresses into the same wallet that exists on the node.
230+
```
231+
curl -X POST https://localhost:8090/api/v1/wallets/Ae2tdPwUPEZLXCZQkmwcatABSc5Fw1bp3dk5nBkNnkNHy6teLdxqQm8NPgW/accounts/2147483648/addresses \
232+
-H "Accept: application/json; charset=utf-8" \
233+
-H "Content-Type: application/json; charset=utf-8" \
234+
--cert ~/wb/cardano-wallet/state-staging/tls/client/client.pem \
235+
--cacert ~/wb/cardano-wallet/state-staging/tls/client/ca.crt \
236+
-d @addresses50k.txt --http1.1 | python -m json.tool
237+
```
238+
239+
### Expected:
240+
The import should be successful. If there are any failures make sure that they concern addresses written down in step 1 above.
241+
Please note: the batch import request with 50k addresses took ~7-9 minutes on the local node for the following hardware spec: Ubuntu Linux, SSD, 16GB RAM, Intel Core i5 (8 cores).
242+
243+
Exemplary response:
244+
```
245+
{
246+
"data": {
247+
"failures": [
248+
"DdzFFzCqrhsovPRUWHeFun6CokFFLNUvzeB31MqW28SFEZf2aaasJCBc1LUQFWBPUqn1FNcFVS5EY9rkxXBJmfeaEZkrdqfjH5dXNo4C"
249+
],
250+
"totalSuccess": 49999
251+
},
252+
"meta": {
253+
"pagination": {
254+
"page": 1,
255+
"perPage": 1,
256+
"totalEntries": 1,
257+
"totalPages": 1
258+
}
259+
},
260+
"status": "success"
261+
}
262+
```

0 commit comments

Comments
 (0)