Skip to content

Commit

Permalink
Merge pull request tronprotocol#6083 from CarlChaoCarl/revert-6034-fe…
Browse files Browse the repository at this point in the history
…ature/optimize_unit_tests_coverage

Revert "feat(test): improve tests coverage"
  • Loading branch information
CodeNinjaEvan authored Nov 22, 2024
2 parents 9d168e8 + e15ecce commit 055ef97
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 2,393 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ subprojects {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "org.mockito:mockito-core:3.10.0"
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.9'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'

testImplementation "org.mockito:mockito-core:2.13.0"
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
27 changes: 1 addition & 26 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ plugins {
id "org.gradle.test-retry" version "1.5.9"
id "org.sonarqube" version "2.6"
id "com.gorylenko.gradle-git-properties" version "2.4.1"
id "io.github.surpsg.offlins" version "0.3.0"
}

gitProperties.failOnNoGitDirectory = false;

apply plugin: 'application'
apply plugin: 'checkstyle'
apply plugin: "io.github.surpsg.offlins"

mainClassName = 'org.tron.program.FullNode'

Expand All @@ -18,7 +16,7 @@ def versions = [
]

jacoco {
toolVersion = "0.8.8"
toolVersion = "0.8.1"
}


Expand Down Expand Up @@ -123,12 +121,10 @@ test {
testLogging {
exceptionFormat = 'full'
}
/*
jacoco {
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
*/
if (isWindows()) {
exclude '**/ShieldedTransferActuatorTest.class'
exclude '**/BackupDbUtilTest.class'
Expand All @@ -145,7 +141,6 @@ test {
}
}

/*
jacocoTestReport {
reports {
xml.enabled true
Expand All @@ -154,26 +149,6 @@ jacocoTestReport {
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
}
*/

offlinsCoverage {
jacocoVersion = '0.8.8' // Optional. By default `0.8.8`

reports {
html.enabled.set true // Optional. By default `true`
html.location.set project.file('build/reports/jacoco/test/html') // Optional. By default `build/reports/jacoco/html`

xml.enabled.set true // Optional. By default `false`
xml.location.set project.file('build/reports/jacoco/test/jacocoTestReport.xml')
// Optional. By default `build/reports/jacoco/coverageReport.xml`

csv.enabled.set true // Optional. By default `false`
csv.location.set project.file('build/reports/jacoco/test/csvCoverage.csv')
// Optional. By default `build/reports/jacoco/coverageReport.csv`
}
}



def binaryRelease(taskName, jarName, mainClass) {
return tasks.create("${taskName}", Jar) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
import org.tron.core.capsule.TransactionCapsule;
import org.tron.p2p.utils.ByteArray;
import org.tron.protos.Protocol;
import org.tron.protos.contract.AssetIssueContractOuterClass;
import org.tron.protos.contract.BalanceContract;
import org.tron.protos.contract.Common;
import org.tron.protos.contract.SmartContractOuterClass;

public class TransactionLogTriggerCapsuleTest {

private static final String OWNER_ADDRESS = "41548794500882809695a8a687866e76d4271a1abc";
private static final String RECEIVER_ADDRESS = "41abd4b9367799eaa3197fecb144eb71de1e049150";
private static final String CONTRACT_ADDRESS = "A0B4750E2CD76E19DCA331BF5D089B71C3C2798548";

public TransactionCapsule transactionCapsule;
public BlockCapsule blockCapsule;
Expand Down Expand Up @@ -178,70 +175,4 @@ public void testConstructorWithCancelAllUnfreezeTrxCapsule() {
triggerCapsule.getTransactionLogTrigger().getExtMap().get(BANDWIDTH.name()).longValue());
}

@Test
public void testConstructorWithTransferCapsule() {
BalanceContract.TransferContract.Builder builder2 =
BalanceContract.TransferContract.newBuilder()
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)))
.setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS)));
transactionCapsule = new TransactionCapsule(builder2.build(),
Protocol.Transaction.Contract.ContractType.TransferContract);

TransactionLogTriggerCapsule triggerCapsule =
new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule);

Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress());
Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress());
}

@Test
public void testConstructorWithTransferAssetCapsule() {
AssetIssueContractOuterClass.TransferAssetContract.Builder builder2 =
AssetIssueContractOuterClass.TransferAssetContract.newBuilder()
.setAssetName(ByteString.copyFrom("AssetName".getBytes()))
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)))
.setToAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS)));
transactionCapsule = new TransactionCapsule(builder2.build(),
Protocol.Transaction.Contract.ContractType.TransferAssetContract);

TransactionLogTriggerCapsule triggerCapsule =
new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule);

Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress());
Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress());
}

@Test
public void testConstructorWithTriggerSmartContract() {
SmartContractOuterClass.TriggerSmartContract.Builder builder2 =
SmartContractOuterClass.TriggerSmartContract.newBuilder()
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)))
.setContractAddress(ByteString.copyFrom(ByteArray.fromHexString(CONTRACT_ADDRESS)));
transactionCapsule = new TransactionCapsule(builder2.build(),
Protocol.Transaction.Contract.ContractType.TriggerSmartContract);

TransactionLogTriggerCapsule triggerCapsule =
new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule);

Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress());
Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getToAddress());
}

@Test
public void testConstructorWithCreateSmartContract() {
SmartContractOuterClass.CreateSmartContract.Builder builder2 =
SmartContractOuterClass.CreateSmartContract.newBuilder()
.setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)));
transactionCapsule = new TransactionCapsule(builder2.build(),
Protocol.Transaction.Contract.ContractType.CreateSmartContract);

TransactionLogTriggerCapsule triggerCapsule =
new TransactionLogTriggerCapsule(transactionCapsule, blockCapsule);

Assert.assertNotNull(triggerCapsule.getTransactionLogTrigger().getFromAddress());
}




}

This file was deleted.

Loading

0 comments on commit 055ef97

Please sign in to comment.