Skip to content

Commit d549d34

Browse files
Add Debug and Display tests for all strkey types (#95)
1 parent b00a82a commit d549d34

2 files changed

Lines changed: 427 additions & 9 deletions

File tree

tests/debug.rs

Lines changed: 180 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use stellar_strkey::*;
22

3-
extern crate proptest;
4-
53
#[test]
6-
fn test_ed25519_public_key() {
4+
fn test_strkey_ed25519_public_key_debug() {
75
assert_eq!(
86
format!(
97
"{:?}",
@@ -18,7 +16,7 @@ fn test_ed25519_public_key() {
1816
}
1917

2018
#[test]
21-
fn test_ed25519_private_key() {
19+
fn test_strkey_ed25519_private_key_debug() {
2220
assert_eq!(
2321
format!(
2422
"{:?}",
@@ -33,7 +31,7 @@ fn test_ed25519_private_key() {
3331
}
3432

3533
#[test]
36-
fn test_contract() {
34+
fn test_strkey_contract_debug() {
3735
assert_eq!(
3836
format!(
3937
"{:?}",
@@ -48,7 +46,7 @@ fn test_contract() {
4846
}
4947

5048
#[test]
51-
fn test_hash_x() {
49+
fn test_strkey_hash_x_debug() {
5250
assert_eq!(
5351
format!(
5452
"{:?}",
@@ -63,7 +61,7 @@ fn test_hash_x() {
6361
}
6462

6563
#[test]
66-
fn test_pre_auth_tx() {
64+
fn test_strkey_pre_auth_tx_debug() {
6765
assert_eq!(
6866
format!(
6967
"{:?}",
@@ -78,7 +76,7 @@ fn test_pre_auth_tx() {
7876
}
7977

8078
#[test]
81-
fn test_ed25519_muxed_account() {
79+
fn test_strkey_ed25519_muxed_account_debug() {
8280
assert_eq!(
8381
format!(
8482
"{:?}",
@@ -96,7 +94,7 @@ fn test_ed25519_muxed_account() {
9694
}
9795

9896
#[test]
99-
fn test_ed25519_signed_payload() {
97+
fn test_strkey_ed25519_signed_payload_debug() {
10098
assert_eq!(
10199
format!(
102100
"{:?}",
@@ -112,3 +110,176 @@ fn test_ed25519_signed_payload() {
112110
"SignedPayloadEd25519(SignedPayload(0000000000000000000000000000000000000000000000000000000000000000, 01020304))",
113111
);
114112
}
113+
114+
#[test]
115+
fn test_strkey_liquidity_pool_debug() {
116+
assert_eq!(
117+
format!(
118+
"{:?}",
119+
Strkey::LiquidityPool(LiquidityPool([
120+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
122+
0x00, 0x00, 0x00, 0x00,
123+
]))
124+
),
125+
"LiquidityPool(LiquidityPool(0000000000000000000000000000000000000000000000000000000000000000))",
126+
);
127+
}
128+
129+
#[test]
130+
fn test_strkey_claimable_balance_debug() {
131+
assert_eq!(
132+
format!(
133+
"{:?}",
134+
Strkey::ClaimableBalance(ClaimableBalance::V0([
135+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137+
0x00, 0x00, 0x00, 0x00,
138+
]))
139+
),
140+
"ClaimableBalance(ClaimableBalance(V0(0000000000000000000000000000000000000000000000000000000000000000)))",
141+
);
142+
}
143+
144+
// Inner type debug tests
145+
146+
#[test]
147+
fn test_ed25519_public_key_debug() {
148+
assert_eq!(
149+
format!(
150+
"{:?}",
151+
ed25519::PublicKey([
152+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154+
0x00, 0x00, 0x00, 0x00,
155+
])
156+
),
157+
"PublicKey(0000000000000000000000000000000000000000000000000000000000000000)",
158+
);
159+
}
160+
161+
#[test]
162+
fn test_ed25519_private_key_debug() {
163+
assert_eq!(
164+
format!(
165+
"{:?}",
166+
ed25519::PrivateKey([
167+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169+
0x00, 0x00, 0x00, 0x00,
170+
])
171+
),
172+
"PrivateKey(0000000000000000000000000000000000000000000000000000000000000000)",
173+
);
174+
}
175+
176+
#[test]
177+
fn test_pre_auth_tx_debug() {
178+
assert_eq!(
179+
format!(
180+
"{:?}",
181+
PreAuthTx([
182+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184+
0x00, 0x00, 0x00, 0x00,
185+
])
186+
),
187+
"PreAuthTx(0000000000000000000000000000000000000000000000000000000000000000)",
188+
);
189+
}
190+
191+
#[test]
192+
fn test_hash_x_debug() {
193+
assert_eq!(
194+
format!(
195+
"{:?}",
196+
HashX([
197+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199+
0x00, 0x00, 0x00, 0x00,
200+
])
201+
),
202+
"HashX(0000000000000000000000000000000000000000000000000000000000000000)",
203+
);
204+
}
205+
206+
#[test]
207+
fn test_ed25519_muxed_account_debug() {
208+
assert_eq!(
209+
format!(
210+
"{:?}",
211+
ed25519::MuxedAccount {
212+
ed25519: [
213+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216+
],
217+
id: 0,
218+
}
219+
),
220+
"MuxedAccount(0000000000000000000000000000000000000000000000000000000000000000, 0)",
221+
);
222+
}
223+
224+
#[test]
225+
fn test_ed25519_signed_payload_debug() {
226+
assert_eq!(
227+
format!(
228+
"{:?}",
229+
ed25519::SignedPayload {
230+
ed25519: [
231+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234+
],
235+
payload: [1, 2, 3, 4].into(),
236+
}
237+
),
238+
"SignedPayload(0000000000000000000000000000000000000000000000000000000000000000, 01020304)",
239+
);
240+
}
241+
242+
#[test]
243+
fn test_contract_debug() {
244+
assert_eq!(
245+
format!(
246+
"{:?}",
247+
Contract([
248+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250+
0x00, 0x00, 0x00, 0x00,
251+
])
252+
),
253+
"Contract(0000000000000000000000000000000000000000000000000000000000000000)",
254+
);
255+
}
256+
257+
#[test]
258+
fn test_liquidity_pool_debug() {
259+
assert_eq!(
260+
format!(
261+
"{:?}",
262+
LiquidityPool([
263+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265+
0x00, 0x00, 0x00, 0x00,
266+
])
267+
),
268+
"LiquidityPool(0000000000000000000000000000000000000000000000000000000000000000)",
269+
);
270+
}
271+
272+
#[test]
273+
fn test_claimable_balance_debug() {
274+
assert_eq!(
275+
format!(
276+
"{:?}",
277+
ClaimableBalance::V0([
278+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
280+
0x00, 0x00, 0x00, 0x00,
281+
])
282+
),
283+
"ClaimableBalance(V0(0000000000000000000000000000000000000000000000000000000000000000))",
284+
);
285+
}

0 commit comments

Comments
 (0)