From 09f762876711202b259d39c95595eac9a0e31d94 Mon Sep 17 00:00:00 2001 From: Clifton King Date: Tue, 8 Jun 2021 18:44:15 -0500 Subject: [PATCH 1/3] fix sign test in remote_signer --- remote_signer/tests/sign.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote_signer/tests/sign.rs b/remote_signer/tests/sign.rs index ee124c80db3..7b07c4c3af1 100644 --- a/remote_signer/tests/sign.rs +++ b/remote_signer/tests/sign.rs @@ -281,7 +281,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0xINVALID_VALUE_\",\"current_version\":\"0x02020202\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \\\'I\\\', index: 0 })\", line: 1, column: 237097)", + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237097)", ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"INVALID_VALUE\",\"epoch\":\"1545\"},", @@ -293,7 +293,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0xINVALID_VALUE_\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \\\'I\\\', index: 0 })\", line: 1, column: 237128)" + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237128)" ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0x02020202\",\"epoch\":},", From e417657137e1caab88793df87f7b9f1d6efa1450 Mon Sep 17 00:00:00 2001 From: Clifton King Date: Fri, 11 Jun 2021 14:15:15 -0500 Subject: [PATCH 2/3] deserialized error msg escape char handling --- remote_signer/tests/sign.rs | 4 ++-- remote_signer/tests/sign_randao.rs | 4 ++-- testing/remote_signer_test/src/consumer.rs | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/remote_signer/tests/sign.rs b/remote_signer/tests/sign.rs index 7b07c4c3af1..49bb9da7e54 100644 --- a/remote_signer/tests/sign.rs +++ b/remote_signer/tests/sign.rs @@ -281,7 +281,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0xINVALID_VALUE_\",\"current_version\":\"0x02020202\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237097)", + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \"I\", index: 0 })\", line: 1, column: 237097)", ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"INVALID_VALUE\",\"epoch\":\"1545\"},", @@ -293,7 +293,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0xINVALID_VALUE_\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237128)" + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \"I\", index: 0 })\", line: 1, column: 237128)" ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0x02020202\",\"epoch\":},", diff --git a/remote_signer/tests/sign_randao.rs b/remote_signer/tests/sign_randao.rs index e2d7a9cf609..738c382420d 100644 --- a/remote_signer/tests/sign_randao.rs +++ b/remote_signer/tests/sign_randao.rs @@ -30,11 +30,11 @@ mod sign_randao { testcase( "\"beacon_proposer\"", - "Unable to parse block from JSON: Error(\"invalid type: string \\\"49463\\\", expected struct BeaconBlock\", line: 0, column: 0)" + "Unable to parse block from JSON: Error(\"invalid type: string \"49463\", expected struct BeaconBlock\", line: 0, column: 0)" ); testcase( "\"beacon_attester\"", - "Unable to parse attestation from JSON: Error(\"invalid type: string \\\"49463\\\", expected struct AttestationData\", line: 0, column: 0)" + "Unable to parse attestation from JSON: Error(\"invalid type: string \"49463\", expected struct AttestationData\", line: 0, column: 0)" ); testcase("\"blah\"", "Unsupported bls_domain parameter: blah"); diff --git a/testing/remote_signer_test/src/consumer.rs b/testing/remote_signer_test/src/consumer.rs index 377d0c489d1..d960f0ce893 100644 --- a/testing/remote_signer_test/src/consumer.rs +++ b/testing/remote_signer_test/src/consumer.rs @@ -141,5 +141,13 @@ pub fn assert_sign_ok(resp: ApiTestResponse, expected_signature: &str) { pub fn assert_sign_error(resp: ApiTestResponse, http_status: u16, error_msg: &str) { assert_eq!(resp.status, http_status); - assert_eq!(resp.json["error"].as_str().unwrap(), error_msg); + assert_eq!( + resp.json["error"] + .as_str() + .unwrap() + // cross-platform compatiblity + .replace("\\", "") + .replace("'", "\""), + error_msg + ); } From 22d5c1ce567d4a08077de148b91d054bb39eae32 Mon Sep 17 00:00:00 2001 From: Clifton King Date: Fri, 11 Jun 2021 17:53:13 -0500 Subject: [PATCH 3/3] just remove escape characters --- remote_signer/tests/sign.rs | 4 ++-- testing/remote_signer_test/src/consumer.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/remote_signer/tests/sign.rs b/remote_signer/tests/sign.rs index 49bb9da7e54..7b07c4c3af1 100644 --- a/remote_signer/tests/sign.rs +++ b/remote_signer/tests/sign.rs @@ -281,7 +281,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0xINVALID_VALUE_\",\"current_version\":\"0x02020202\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \"I\", index: 0 })\", line: 1, column: 237097)", + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237097)", ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"INVALID_VALUE\",\"epoch\":\"1545\"},", @@ -293,7 +293,7 @@ mod sign { ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0xINVALID_VALUE_\",\"epoch\":\"1545\"},", - "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: \"I\", index: 0 })\", line: 1, column: 237128)" + "Unable to parse body message from JSON: Error(\"invalid hex (InvalidHexCharacter { c: 'I', index: 0 })\", line: 1, column: 237128)" ); testcase( "\"fork\":{\"previous_version\":\"0x01010101\",\"current_version\":\"0x02020202\",\"epoch\":},", diff --git a/testing/remote_signer_test/src/consumer.rs b/testing/remote_signer_test/src/consumer.rs index d960f0ce893..3465232702a 100644 --- a/testing/remote_signer_test/src/consumer.rs +++ b/testing/remote_signer_test/src/consumer.rs @@ -146,8 +146,7 @@ pub fn assert_sign_error(resp: ApiTestResponse, http_status: u16, error_msg: &st .as_str() .unwrap() // cross-platform compatiblity - .replace("\\", "") - .replace("'", "\""), + .replace("\\", ""), error_msg ); }