Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] POC-create a workflow for executing tests with transaction executor #9755

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 89 additions & 28 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- "main"
- "release/**"

push:
branches:
- "main"
Expand All @@ -23,40 +24,99 @@ env:
CGO_ENABLED: 1

jobs:
build:
name: Build
# build:
# name: Build
# runs-on: mirror-node-linux-large
# strategy:
# matrix:
# project:
# - common
# - graphql
# - grpc
# - importer
# - monitor
# - rest
# - rest-java
# - "rest:check-state-proof"
# - "rest:monitoring"
# - rosetta
# - test
# - web3
# schema:
# - v1
# - v2
# exclude:
# - project: common
# schema: v2
# - project: monitor
# schema: v2
# - project: rest:check-state-proof
# schema: v2
# - project: rest:monitoring
# schema: v2
# - project: rosetta
# schema: v2
# - project: test
# schema: v2
# timeout-minutes: 40 # increase it from 20 minutes since some jobs often run longer on self-hosted runners
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
# with:
# egress-policy: audit
#
# - name: Checkout Code
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
#
# - name: Setup Node
# uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
# with:
# node-version: 18
#
# - name: Install JDK
# uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
# with:
# distribution: temurin
# java-version: 21
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
#
# - name: Setup GCC Compiler
# if: ${{ matrix.project == 'rosetta' }}
# run: |
# sudo apt-get update
# sudo apt-get install -y --no-install-recommends gcc libc-dev libc6-dev
#
# - name: Execute Gradle
# env:
# MIRROR_NODE_SCHEMA: ${{ matrix.schema}}
# SPRING_PROFILES_ACTIVE: ${{ matrix.schema}}
# run: ./gradlew :${{matrix.project}}:build --scan ${{ secrets.GRADLE_ARGS }}
#
# - name: TEST Execute with flag
# if: ${{ matrix.project == 'web3' }}
# env:
# MIRROR_NODE_SCHEMA: ${{ matrix.project == 'web3'}}
# SPRING_PROFILES_ACTIVE: ${{ matrix.schema}}
# run: ./gradlew :web3:test -DtestFlag=true --scan
#
# - name: Upload coverage report
# uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# if: ${{ matrix.schema == 'v1' && matrix.project != 'rest:monitoring' && matrix.project != 'test' && always() }}

testReusable:
name: Test with Flag
runs-on: mirror-node-linux-large
strategy:
matrix:
project:
- common
- graphql
- grpc
- importer
- monitor
- rest
- rest-java
- "rest:check-state-proof"
- "rest:monitoring"
- rosetta
- test
- web3
schema:
- v1
- v2
exclude:
- project: common
schema: v2
- project: monitor
schema: v2
- project: rest:check-state-proof
schema: v2
- project: rest:monitoring
schema: v2
- project: rosetta
schema: v2
- project: test
schema: v2
timeout-minutes: 40 # increase it from 20 minutes since some jobs often run longer on self-hosted runners
steps:
- name: Harden Runner
Expand Down Expand Up @@ -87,14 +147,15 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends gcc libc-dev libc6-dev

- name: Execute Gradle
- name: TEST WITH FLAG -> Execute Gradle
env:
MIRROR_NODE_SCHEMA: ${{ matrix.schema}}
SPRING_PROFILES_ACTIVE: ${{ matrix.schema}}
run: ./gradlew :${{matrix.project}}:build --scan ${{ secrets.GRADLE_ARGS }}
run: ./gradlew :${{matrix.project}}:build -PtestFlag=true --scan ${{ secrets.GRADLE_ARGS }}

- name: Upload coverage report
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: ${{ matrix.schema == 'v1' && matrix.project != 'rest:monitoring' && matrix.project != 'test' && always() }}

12 changes: 11 additions & 1 deletion hedera-mirror-web3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import org.gradle.internal.classpath.Instrumented.systemProperty
import java.net.HttpURLConnection
import java.net.URI
import org.web3j.solidity.gradle.plugin.SolidityCompile
Expand Down Expand Up @@ -125,7 +126,16 @@ tasks.bootRun { jvmArgs = listOf("--enable-preview") }

tasks.compileJava { options.compilerArgs.add("--enable-preview") }

tasks.test { jvmArgs = listOf("--enable-preview") }
tasks.test { jvmArgs = listOf("--enable-preview")

// Set default value for testFlag if not provided
val testFlagValue = if (project.hasProperty("testFlag")) {
project.property("testFlag") as String
} else {
"false"
}
systemProperty("testFlag", testFlagValue)
}

tasks.openApiGenerate { mustRunAfter(tasks.named("resolveSolidity")) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.hedera.services.store.models.Id;
import com.hedera.services.utils.EntityIdUtils;
import com.hederahashgraph.api.proto.java.Key.KeyCase;
import com.hederahashgraph.api.proto.java.ScheduleOuterClass;
import com.swirlds.base.time.Time;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
Expand All @@ -67,10 +68,12 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.datatypes.Address;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Value;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.tx.Contract;

Expand Down Expand Up @@ -185,37 +188,53 @@ void approveNFT(final Boolean approve) throws Exception {
}

@Test
void setApprovalForAll() throws Exception {
@Tag("run-this")
// @Value("${spring.test.reusableServicesFlag:false}")
void TESTsetApprovalForAll() throws Exception {
// Given
final var spender = accountEntityPersist();

final var tokenEntity =
domainBuilder.entity().customize(e -> e.type(EntityType.TOKEN)).persist();
domainBuilder
.token()
.customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.NON_FUNGIBLE_UNIQUE))
.persist();

tokenAccountPersist(tokenEntity, spender);

final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);

final var contractAddress = Address.fromHexString(contract.getContractAddress());
final var contractEntityId = entityIdFromEvmAddress(contractAddress);
tokenAccountPersist(tokenEntity, contractEntityId.getId());

domainBuilder
.nft()
.customize(n -> n.tokenId(tokenEntity.getId()).serialNumber(1L).accountId(contractEntityId))
.persist();

// When
final var functionCall = contract.call_setApprovalForAllExternal(
getAddressFromEntity(tokenEntity), getAddressFromEntity(spender), Boolean.TRUE);

// Then
verifyEthCallAndEstimateGas(functionCall, contract, ZERO_VALUE);
verifyOpcodeTracerCall(functionCall.encodeFunctionCall(), contract);
String testFlagValue = System.getProperty("testFlag", "false");
boolean testFlag = Boolean.parseBoolean(testFlagValue);

System.out.println(testFlagValue);
System.out.println("TEST FLAG IS SET TO " + testFlagValue);
assertThat(testFlag).isTrue();
// if(testFlag){
// System.out.println("TEST FLAG IS SET TO TRUE");
// } else {
// System.out.println("TEST FLAG IS SET TO FALSE");
// }
//


// final var spender = accountEntityPersist();
//
// final var tokenEntity =
// domainBuilder.entity().customize(e -> e.type(EntityType.TOKEN)).persist();
// domainBuilder
// .token()
// .customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.NON_FUNGIBLE_UNIQUE))
// .persist();
//
// tokenAccountPersist(tokenEntity, spender);
//
// final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);
//
// final var contractAddress = Address.fromHexString(contract.getContractAddress());
// final var contractEntityId = entityIdFromEvmAddress(contractAddress);
// tokenAccountPersist(tokenEntity, contractEntityId.getId());
//
// domainBuilder
// .nft()
// .customize(n -> n.tokenId(tokenEntity.getId()).serialNumber(1L).accountId(contractEntityId))
// .persist();
//
// // When
// final var functionCall = contract.call_setApprovalForAllExternal(
// getAddressFromEntity(tokenEntity), getAddressFromEntity(spender), Boolean.TRUE);
//
// // Then
// verifyEthCallAndEstimateGas(functionCall, contract, ZERO_VALUE);
// verifyOpcodeTracerCall(functionCall.encodeFunctionCall(), contract);
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ spring:
test:
database:
replace: NONE
# reusableServicesFlag: ${testFlag:false}
Loading