Commit 7186913
Merge #1623
1623: Mock metadata aggregation server r=KtorZ a=KtorZ
# Issue Number
<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#1597
# Overview
<!-- Detail in a few bullet points the work accomplished in this PR -->
- 64052c5
📍 **Basic skeleton for refreshing metadata.**
Still requires proper log messages and error handling. But this already allows some level of testing.
- 7be9a83
📍 **log events while refreshing metadata**
- 566d95d
📍 **handle 404 in the metadata client directly**
So that the calling code needs not to worry about the 'ClientError'. Any error becomes unexpected and all errors can be treated consistently.
- 398bb78
📍 **merge 'refresh' and 'Client' so that the client is already caching results by itself.**
This makes it slightly easier to use from a consumer perspective. Once one has a handle on a 'Client IO Api' it can makes requests without having to
worry about whether they get cached or not. Doing so, I also removed the 'ClientError' from the response. The client does handle error by itself and
log messages accordingly. A caller would likely not do anything more than relogging the error.
Plus, from the caller perspective, a metadata not being there and the request failing has pretty much the same end: no metadata.
- 98a499d
📍 **write small unit / property tests to exercise the client.**
Written as property so we get some fuzzy testing and test cases with and without metadata
Fails nicely with each log messages obtained in the run:
```
Assertion failed (after 1 test):
PoolId {getPoolId = "\SOH\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\SOH\SOH\NUL\SOH\SOH\SOH\SOH\NUL\SOH\NUL\SOH\SOH\SOH\NUL\SOH\NUL\SOH\NUL\NUL\NUL\SOH\SOH\NUL"}
MsgRefreshingMetadata (PoolId {getPoolId = "\SOH\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\SOH\SOH\NUL\SOH\SOH\SOH\SOH\NUL\SOH\NUL\SOH\SOH\SOH\NUL\SOH\NUL\SOH\NUL\NUL\NUL\SOH\SOH\NUL"}) (Just (StakePoolOffChainMetadata {ticker = StakePoolTicker {unStakePoolTicker = "VUHQ"}, name = "_-NfdG\21785\&0?-wjm'\\.G{0MtJ4E", description = "_-NfdG\21785\&0?-wjm'\\.G{0MtJ4E", homepage = "https://\tXuP9h>v\ETXXM\FSUHd\ACKp\SOH\FS\SOHg\DEL$.io"}),2020-05-04 23:31:26.917183969 UTC)
MsgUsingCached (PoolId {getPoolId = "\SOH\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\SOH\SOH\NUL\SOH\SOH\SOH\SOH\NUL\SOH\NUL\SOH\SOH\SOH\NUL\SOH\NUL\SOH\NUL\NUL\NUL\SOH\SOH\NUL"}) 2020-05-04 23:31:26.917183969 UTC
```
- 51cf00a
📍 **add an extra scenario illustrating a unhappy path**
```
Cardano.Pool.Metadata
Metadata - MockServer
Mock Server works as intended
+++ OK, passed 100 tests:
51% Got Valid Metadata
49% No Corresponding Metadata
Cache metadata when called twice within the TTL
+++ OK, passed 10 tests.
Fetch them again when fetching outside of the TTL
+++ OK, passed 10 tests.
Returns 'Nothing' and a warning log message on failure
+++ OK, passed 1 test.
```
- c76f29d
📍 **move 'count' to 'Test.Util.Trace' with extra comments'**
<!--
Don't forget to:
✓ Self-review your changes to make sure nothing unexpected slipped through
✓ Assign yourself to the PR
✓ Assign one or several reviewer(s)
✓ Once created, link this PR to its corresponding ticket
✓ Assign the PR to a corresponding milestone
✓ Acknowledge any changes required to the Wiki
-->
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Co-authored-by: IOHK <devops+stack-project@iohk.io>File tree
7 files changed
+284
-43
lines changed- lib
- core
- src/Cardano/Pool
- test/unit/Cardano/Pool
- test-utils
- src/Test/Utils
- nix/.stack.nix
7 files changed
+284
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | 219 | | |
221 | 220 | | |
222 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
| |||
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
| 49 | + | |
| 50 | + | |
34 | 51 | | |
35 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
36 | 61 | | |
37 | 62 | | |
| 63 | + | |
| 64 | + | |
38 | 65 | | |
39 | 66 | | |
40 | 67 | | |
| |||
44 | 71 | | |
45 | 72 | | |
46 | 73 | | |
| 74 | + | |
47 | 75 | | |
48 | 76 | | |
49 | 77 | | |
| 78 | + | |
| 79 | + | |
50 | 80 | | |
51 | 81 | | |
52 | 82 | | |
| |||
65 | 95 | | |
66 | 96 | | |
67 | 97 | | |
68 | | - | |
| 98 | + | |
69 | 99 | | |
70 | 100 | | |
71 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
72 | 120 | | |
73 | 121 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
81 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
82 | 146 | | |
83 | 147 | | |
84 | | - | |
| 148 | + | |
85 | 149 | | |
86 | | - | |
| 150 | + | |
87 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
0 commit comments