Skip to content

Commit a526145

Browse files
committed
Fix remote signer test (#2400)
## Proposed Changes Unescape text for json comparison in: https://github.com/sigp/lighthouse/blob/3a24ca5f14c6e6d6612fd43eca82aa0c1e6aba16/remote_signer/tests/sign.rs#L282-L285 Which causes this error: ``` ---- sign::invalid_field_fork stdout ---- thread 'sign::invalid_field_fork' panicked at 'assertion failed: `(left == right)` left: `"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237097)"`, right: `"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \\'I\\', index: 0 })\", line: 1, column: 237097)"`', testing/remote_signer_test/src/consumer.rs:144:5 ``` This is my first contribution and happy to receive feedback if you have any. Thanks
1 parent dffe31c commit a526145

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

remote_signer/tests/sign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ mod sign {
281281
);
282282
testcase(
283283
"\"fork\":{\"previous_version\":\"0xINVALID_VALUE_\",\"current_version\":\"0x02020202\",\"epoch\":\"1545\"},",
284-
"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \\\'I\\\', index: 0 })\", line: 1, column: 237097)",
284+
"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237097)",
285285
);
286286
testcase(
287287
"\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"INVALID_VALUE\",\"epoch\":\"1545\"},",
@@ -293,7 +293,7 @@ mod sign {
293293
);
294294
testcase(
295295
"\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0xINVALID_VALUE_\",\"epoch\":\"1545\"},",
296-
"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \\\'I\\\', index: 0 })\", line: 1, column: 237128)"
296+
"Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237128)"
297297
);
298298
testcase(
299299
"\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0x02020202\",\"epoch\":},",

remote_signer/tests/sign_randao.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ mod sign_randao {
3030

3131
testcase(
3232
"\"beacon_proposer\"",
33-
"Unable to parse block from JSON: Error(\"invalid type: string \\\"49463\\\", expected struct BeaconBlock\", line: 0, column: 0)"
33+
"Unable to parse block from JSON: Error(\"invalid type: string \"49463\", expected struct BeaconBlock\", line: 0, column: 0)"
3434
);
3535
testcase(
3636
"\"beacon_attester\"",
37-
"Unable to parse attestation from JSON: Error(\"invalid type: string \\\"49463\\\", expected struct AttestationData\", line: 0, column: 0)"
37+
"Unable to parse attestation from JSON: Error(\"invalid type: string \"49463\", expected struct AttestationData\", line: 0, column: 0)"
3838
);
3939
testcase("\"blah\"", "Unsupported bls_domain parameter: blah");
4040

testing/remote_signer_test/src/consumer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,12 @@ pub fn assert_sign_ok(resp: ApiTestResponse, expected_signature: &str) {
141141

142142
pub fn assert_sign_error(resp: ApiTestResponse, http_status: u16, error_msg: &str) {
143143
assert_eq!(resp.status, http_status);
144-
assert_eq!(resp.json["error"].as_str().unwrap(), error_msg);
144+
assert_eq!(
145+
resp.json["error"]
146+
.as_str()
147+
.unwrap()
148+
// cross-platform compatiblity
149+
.replace("\\", ""),
150+
error_msg
151+
);
145152
}

0 commit comments

Comments
 (0)