forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds acceptance test reproducing an issue where built blocks have pro…
…ofs > txs Signed-off-by: Justin Florentine <[email protected]>
- Loading branch information
Showing
26 changed files
with
2,205 additions
and
3,315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...edger/besu/tests/acceptance/jsonrpc/ExecutionEngineCancunBlockBulidingAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright contributors to Hyperledger Besu. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.tests.acceptance.jsonrpc; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.hyperledger.besu.config.JsonUtil; | ||
import org.hyperledger.besu.tests.acceptance.dsl.rpc.JsonRpcTestCase; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.fasterxml.jackson.databind.node.JsonNodeType; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import okhttp3.Call; | ||
import okhttp3.Response; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class ExecutionEngineCancunBlockBulidingAcceptanceTest extends AbstractJsonRpcTest { | ||
private static final String GENESIS_FILE = "/jsonrpc/engine/cancun/genesis.json"; | ||
private static final String TEST_CASE_PATH = "/jsonrpc/engine/cancun/test-cases/block-production"; | ||
|
||
private static JsonRpcTestsContext testsContext; | ||
|
||
public ExecutionEngineCancunBlockBulidingAcceptanceTest(final String ignored, final URI testCaseFileURI) { | ||
super(ignored, testsContext, testCaseFileURI); | ||
} | ||
|
||
@BeforeClass | ||
public static void init() throws IOException { | ||
testsContext = new JsonRpcTestsContext(GENESIS_FILE); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> testCases() throws URISyntaxException { | ||
return testCases(TEST_CASE_PATH); | ||
} | ||
|
||
@Override | ||
protected void evaluateResponse( | ||
final Response response, | ||
final Call testRequest, | ||
final JsonRpcTestCase testCase, | ||
final URL url) { | ||
if (url.toString().endsWith("10_cancun_build_on_genesis.json")) { | ||
// if we just asked the node to build, give it some time to build | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
if (url.toString().endsWith("12_cancun_get_built_block.json")) { | ||
try { | ||
final ObjectNode rpcResponse = JsonUtil.objectNodeFromString(response.body().string()); | ||
final ObjectNode result = (ObjectNode) rpcResponse.get("result"); | ||
final ObjectNode execPayload = (ObjectNode) result.get("executionPayload"); | ||
final ObjectNode blobsBundle = (ObjectNode) result.get("blobsBundle"); | ||
assertThat(execPayload.get("transactions").getNodeType()).isEqualTo(JsonNodeType.ARRAY); | ||
final ArrayNode transactions = (ArrayNode) execPayload.get("transactions"); | ||
assertThat(blobsBundle.get("commitments").getNodeType()).isEqualTo(JsonNodeType.ARRAY); | ||
final ArrayNode commitments = (ArrayNode) blobsBundle.get("commitments"); | ||
assertThat(blobsBundle.get("blobs").getNodeType()).isEqualTo(JsonNodeType.ARRAY); | ||
final ArrayNode blobs = (ArrayNode) blobsBundle.get("blobs"); | ||
final ArrayNode proofs = (ArrayNode) blobsBundle.get("proofs"); | ||
assertThat(transactions.size()).isEqualTo(commitments.size()); | ||
assertThat(transactions.size()).isEqualTo(blobs.size()); | ||
assertThat(transactions.size()).isEqualTo(proofs.size()); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
testsContext.cluster.close(); | ||
} | ||
} |
Oops, something went wrong.