@Test
  public void shouldPersistCodeDelegationAfterRevert() throws IOException {
    final long GAS_LIMIT = 1_000_000L;

    // check the authorizer has no code before the transaction
    final Bytes authorizerCodeBeforeCodeDelegation =
        besuNode.execute(ethTransactions.getCode(authorizer));
    assertThat(authorizerCodeBeforeCodeDelegation).isEqualTo(Bytes.EMPTY);

    // valid 7702 code delegation to SEND_ALL_ETH_CONTRACT_ADDRESS
    final CodeDelegation codeDelegation =
        org.hyperledger.besu.ethereum.core.CodeDelegation.builder()
            .chainId(BigInteger.valueOf(20211))
            .nonce(0L)
            .address(SEND_ALL_ETH_CONTRACT_ADDRESS)
            .signAndBuild(
                secp256k1.createKeyPair(
                    secp256k1.createPrivateKey(AUTHORIZER_PRIVATE_KEY.toUnsignedBigInteger())));

    // the transaction will revert, because the to address is a contract that always reverts
    final Transaction tx =
        Transaction.builder()
            .type(TransactionType.DELEGATE_CODE)
            .chainId(BigInteger.valueOf(20211))
            .nonce(0)
            .maxPriorityFeePerGas(Wei.of(1_000_000_000))
            .maxFeePerGas(Wei.fromHexString("0x02540BE400"))
            .gasLimit(GAS_LIMIT)
            .to(ALWAYS_REVERT_CONTRACT_ADDRESS)
            .value(Wei.ZERO)
            .payload(Bytes.EMPTY)
            .codeDelegations(List.of(codeDelegation))
            .signAndBuild(
                secp256k1.createKeyPair(
                    secp256k1.createPrivateKey(
                        TRANSACTION_SPONSOR_PRIVATE_KEY.toUnsignedBigInteger())));

    // include the tx in the next block
    final String txHash =
        besuNode.execute(ethTransactions.sendRawTransaction(tx.encoded().toHexString()));
    testHelper.buildNewBlock();

    // check that the transaction was included and has indeed reverted
    Optional<TransactionReceipt> maybeTransactionReceipt =
        besuNode.execute(ethTransactions.getTransactionReceipt(txHash));
    assertThat(maybeTransactionReceipt).isPresent();
    assertThat(maybeTransactionReceipt.get().getStatus()).isEqualTo("0x0");

    // check the authorizer has the code delegation after the transaction even though it has
    // reverted
    final Bytes expectedCode =
        Bytes.concatenate(Bytes.fromHexString("ef0100"), SEND_ALL_ETH_CONTRACT_ADDRESS);
    final Bytes authorizerCode = besuNode.execute(ethTransactions.getCode(authorizer));
    assertThat(authorizerCode).isEqualTo(expectedCode);
  }
EIP-7702 code delegation should be persisted even if the transaction that contains the
authorization is reverted.
acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/CodeDelegationTransactionAcceptanceTest.java