nimbus-eth2
nimbus-eth2 copied to clipboard
Restore the REST API tests for the `/eth/v{1,2}/validator/blocks/slot` calls
During the development of https://github.com/status-im/nimbus-eth2/pull/3639, the tests covering the /eth/v{1,2}/validator/blocks/slot calls had to be removed because they featured invalid RANDAO reveal values (invalid epoch signatures). Since the restapi.sh script is generating fresh validators on each run, it will be difficult to fix the problem within the current design. Two viable options for going forward are:
-
Use static validator keystores committed to git, compute the correct randao value with custom code and enter it in the static json file. The downside of this approach would be the difficult procedure for updating the json files.
-
Add support for tests defined through Nim code where some of the values can be computed dynamically. Implement the code for computing the correct randao value.
For reference, here is a patch restoring the tests in their non-valid form:
diff --git a/ncli/resttest-rules.json b/ncli/resttest-rules.json
index cb2964e7..b05e662a 100644
--- a/ncli/resttest-rules.json
+++ b/ncli/resttest-rules.json
@@ -2972,6 +2972,18 @@
"status": {"operator": "equals", "value": "400"}
}
},
+ {
+ "topics": ["validator", "blocks"],
+ "request": {
+ "url": "/eth/v1/validator/blocks/1?randao_reveal=0x97897b5e8526b4d0f808e7b60bcd1942935b124720bd5156da54c54adc25fe458ef7c934b4e5018afe4659978b06e6510797e5cc7fc31f329035ec6a46889ee9aea375d57b22be71dd4ff181b7f1a07b9199e73c2b80e39e04ba904596d9e4db",
+ "headers": {"Accept": "application/json"}
+ },
+ "response": {
+ "status": {"operator": "equals", "value": "200"},
+ "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
+ "body": [{"operator": "jstructcmps", "start": ["data"], "value": {"slot": "", "proposer_index": "", "parent_root": "", "state_root": "", "body": {"randao_reveal": "", "eth1_data": {"deposit_root": "", "deposit_count": "", "block_hash": ""}, "graffiti": "", "proposer_slashings": [], "attester_slashings": [], "attestations": [], "deposits": [], "voluntary_exits": []}}}]
+ }
+ },
{
"topics": ["validator", "blocksV2"],
"request": {
@@ -2982,6 +2994,18 @@
"status": {"operator": "equals", "value": "400"}
}
},
+ {
+ "topics": ["validator", "blocksV2"],
+ "request": {
+ "url": "/eth/v2/validator/blocks/1?randao_reveal=0x97897b5e8526b4d0f808e7b60bcd1942935b124720bd5156da54c54adc25fe458ef7c934b4e5018afe4659978b06e6510797e5cc7fc31f329035ec6a46889ee9aea375d57b22be71dd4ff181b7f1a07b9199e73c2b80e39e04ba904596d9e4db",
+ "headers": {"Accept": "application/json"}
+ },
+ "response": {
+ "status": {"operator": "equals", "value": "200"},
+ "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
+ "body": [{"operator": "jstructcmps", "start": ["data"], "value": {"slot": "", "proposer_index": "", "parent_root": "", "state_root": "", "body": {"randao_reveal": "", "eth1_data": {"deposit_root": "", "deposit_count": "", "block_hash": ""}, "graffiti": "", "proposer_slashings": [], "attester_slashings": [], "attestations": [], "deposits": [], "voluntary_exits": []}}}]
+ }
+ },
{
"topics": ["validator", "attestation_data"],
"request": {